C#代码
  1. /// <summary>   
  2. /// 用递归方法删除文件夹目录及文件   
  3. /// </summary>   
  4. /// <param name="dir">带文件夹名的路径</param>   
  5. public void DeleteFolder(string dir)   
  6. {   
  7.     if (Directory.Exists(dir)) //如果存在这个文件夹删除之   
  8.      {   
  9.         foreach (string d in Directory.GetFileSystemEntries(dir))   
  10.          {   
  11.             if (File.Exists(d))   
  12.                  File.Delete(d); //直接删除其中的文件                           
  13.             else  
  14.                  DeleteFolder(d); //递归删除子文件夹   
  15.          }   
  16.          Directory.Delete(dir, true); //删除已空文件夹                    
  17.      }   
  18. }  


确保您具有足够的权限 对路径 的访问被拒绝 

删除权限设置: 
在web.config中的<system.web>下加入<identity impersonate="true"/> 

即:
  1. <system.web>  
  2. <identity impersonate="true"/>  

转自:http://www.99mianfei.net/article/html/2751.html

相关文章:

  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2022-03-08
  • 2021-11-12
  • 2022-12-23
猜你喜欢
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2021-06-03
  • 2022-12-23
相关资源
相似解决方案