//选择文件夹
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);//判断文件是否存在
}
C#Winform判断文件和路径是否存在
本文转载:CSDN博客