C# 判斷路徑是否合法

C# 判斷路徑是否合法

Using System.IO;

//
判斷文件路徑是否合法
if (File.Exists(txtAttachment.Text.ToString())==false)
 {
    FrontHelper.ShowMsg(
2"文件不存在"); 
}
//判斷文件夾路徑是否合會
 if (Directory.Exists(txtFilePath.Text))
 {             
     this.Close();
}
else
 {
    // \:為轉義字符
    FrontHelper.ShowMsg(2"\"常用文件夾存放路徑\"存放不正確");
 }
原文地址:https://www.cnblogs.com/scottckt/p/880390.html