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

如果是目录可用:   
    
  DirectoryInfo   TheFolder   =   new   DirectoryInfo(PathName);   
  if   (TheFolder.Exists)   
  {   
  //。。。。。。。。。。。。。   
  }   
    
  如果是文件可用:   
    
  FileInfo   TheFile   =   new   FileInfo(PathName);   
  if   (TheFile.Exists)   
  {   
  //。。。。。。。。。。。。   
  }
using   System.IO;   
  ...   
  if(File.Exists("c:/abc.txt"))   
  {   
      ...   
  }   
  if(Directory.Exists("d:/abc/"))   
  {   
      ...   
  }

posted @ 2013-08-29 17:57  邹邹  Views(183)  Comments(0)    收藏  举报