首页 > 代码库 > C#通过文件路径截取对应的文件夹路径

C#通过文件路径截取对应的文件夹路径

 

 

 try            {                OpenFileDialog openFileDialog = new OpenFileDialog();                string str = comboBox_hexFilePath.Text;                string file = str.Substring(0, str.LastIndexOf("\\") + 1);//去掉了路径                openFileDialog.InitialDirectory = file;                openFileDialog.Filter = "Hex文件|*.hex";                openFileDialog.RestoreDirectory = true;                openFileDialog.FilterIndex = 1;                                  comboBox_hexFilePath.Text = openFileDialog.FileName;//文件名                                    }            }            catch             {                show_info("hex文件选择..");            }

 

C#通过文件路径截取对应的文件夹路径