C# 判断文件和文件夹是否存在

方法1:    
using   System.IO;  
if (File.Exists("d:\a.exe"))   
  {
   //do something
  }
if (Directory.Exists("d:\abc\"))
  {
  //do something
  }
方法2:   
DirectoryInfo aPath = new DirectoryInfo(PathName);   
if   (aPath.Exists)  
  {
  //do something
  }
FileInfo aFile = new FileInfo(PathName);  
  {
  //do something
  }

posted @ 2009-09-25 16:12  novel  阅读(364)  评论(0)    收藏  举报