//选择文件夹  
           FolderBrowserDialog dia = new FolderBrowserDialog();  
           if (dia.ShowDialog() == System.Windows.Forms.DialogResult.OK)  
           {  
               string filePath = dia.SelectedPath;  
  
               Directory.Exists(filePath);//判断文件夹是否存在  
           }  
  
           //选择文件  
           OpenFileDialog dia = new OpenFileDialog();  
           if (dia.ShowDialog() == System.Windows.Forms.DialogResult.OK)  
           {  
               string filePath = dia.SelectedPath;  
  
               File.Exists(filePath);//判断文件是否存在  
           }

 

 

WinForm下判断文件和文件夹是否存在

 

相关文章:

  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-10-29
  • 2021-06-11
猜你喜欢
  • 2021-10-22
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
相关资源
相似解决方案