删除指定路径下的文件
生活随笔
收集整理的這篇文章主要介紹了
删除指定路径下的文件
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
string pathstr = System.Web.HttpContext.Current.Server.MapPath("/FilePath"); if (Directory.Exists(pathstr)){//獲取指定路徑下所有文件夾//string[] folderPaths = Directory.GetDirectories(pathstr);//foreach (string folderPath in folderPaths)// Directory.Delete(folderPath, true);//獲取指定路徑下所有文件string[] filePaths = Directory.GetFiles(pathstr);foreach (string itme in filePaths){System.IO.File.Delete(itme);}}
?
轉載于:https://www.cnblogs.com/shanshuiYiCheng/p/11534816.html
總結
以上是生活随笔為你收集整理的删除指定路径下的文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一文讲透Dubbo负载均衡之最小活跃数算
- 下一篇: 程序员利用测试账户套现千万美元,或面临2