标签:
采用递归的方式实现。
void DeleteDirectory(string path) { var dir = new DirectoryInfo(path); if (dir.Exists) { DirectoryInfo[] childs = dir.GetDirectories(); foreach (DirectoryInfo child in childs) { child.Attributes = FileAttributes.Normal & FileAttributes.Directory; DeleteDirectory(path+"\\"+child.Name); } FileInfo[] files = dir.GetFiles(); foreach (var file in files) { file.Attributes = FileAttributes.Normal; } dir.Delete(true); } }
标签:
原文地址:http://www.cnblogs.com/mark-tubu/p/4970100.html