cnlzj
引用    本文来自网络,属于通用代码。非本人原创、修改。

 

如果是目录可用:

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\"))   
{   
      
//...   
}

 

 

分类:

技术点:

相关文章:

  • 2021-12-22
  • 2021-07-18
  • 2022-01-12
  • 2021-11-18
  • 2021-10-30
  • 2021-05-29
  • 2021-09-22
猜你喜欢
  • 2021-06-01
  • 2021-10-29
  • 2021-06-04
  • 2021-12-06
  • 2021-09-03
  • 2021-04-24
  • 2021-12-24
相关资源
相似解决方案