现在的位置: 首页 > 综合 > 正文

C# 判斷路徑是否合法

2012年06月18日 ⁄ 综合 ⁄ 共 285字 ⁄ 字号 评论关闭
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"\"常用文件夾存放路徑\"存放不正確");
 }

抱歉!评论已关闭.