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文件选择..");
            }

 

posted @ 2015-01-31 16:03  fx427103  阅读(1024)  评论(0编辑  收藏  举报