一、判断文件夹是否存 

1、方法一 

if (Directory.Exists("d:\\pic"))  

{

   MessageBox.Show("存在"); 

}

else

{

   MessageBox.Show("不存在");   

 2、方法二

DirectoryInfo TheFolder = new DirectoryInfo("d:\\pic");   

 if (TheFolder.Exists)  

{

   MessageBox.Show("存在"); 

}

else

{

   MessageBox.Show("不存在");   

二、文件是否存在

if (File.Exists("d:\\pic\\aa.txt"))  

{

   MessageBox.Show("存在"); 

}

else

{

   MessageBox.Show("不存在");   

相关文章:

  • 2021-08-16
  • 2021-06-05
  • 2022-12-23
  • 2021-05-20
  • 2022-02-12
  • 2022-02-08
猜你喜欢
  • 2021-09-26
  • 2021-10-16
  • 2021-05-27
  • 2022-01-28
  • 2021-08-22
  • 2022-12-23
相关资源
相似解决方案