/// <summary> /// 删除文件夹下的文件 /// </summary> /// <param name="FolderName">文件夹路径</param> private void clearFolder(string FolderName) { try { DirectoryInfo dir = new DirectoryInfo(FolderName); foreach (FileInfo fi in dir.GetFiles()) { fi.Delete(); } foreach (DirectoryInfo di in dir.GetDirectories()) { clearFolder(di.FullName); di.Delete(); } } catch (Exception ex) { LogHelper.WriteLog(GetType(), "clearFolder异常错误为"+ex.Message); } }
标签:删除,di,C#,clearFolder,FolderName,DirectoryInfo,文件夹,dir From: https://www.cnblogs.com/lydj/p/17159610.html