阿宽

Nothing is more powerful than habit!
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C# 判斷路徑是否合法

Posted on 2007-09-03 16:35  宽田  阅读(2723)  评论(0编辑  收藏  举报
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"\"常用文件夾存放路徑\"存放不正確");
 }