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

时间:2023-03-10 05:13:00
C#通过文件路径截取对应的文件夹路径
 
 try
{
OpenFileDialog openFileDialog = new OpenFileDialog();
string str = comboBox_hexFilePath.Text;
string file = str.Substring(, str.LastIndexOf("\\") + );//去掉了路径
openFileDialog.InitialDirectory = file; openFileDialog.Filter = "Hex文件|*.hex";
openFileDialog.RestoreDirectory = true;
openFileDialog.FilterIndex = ; comboBox_hexFilePath.Text = openFileDialog.FileName;//文件名 }
}
catch
{
show_info("hex文件选择..");
}