CSharp examples for File IO:Directory
Delete directory by pattern
using System.IO;/*from w ww . j av a2 s. co m*/ using System.Collections.Generic; public class Main{ public static void Delete(this DirectoryInfo di, string searchParttern, bool recursive) { foreach (var fileInfo in di.GetFiles(searchParttern)) { fileInfo.RemoveAttribute(FileAttributes.ReadOnly); fileInfo.RemoveAttribute(FileAttributes.System); fileInfo.Delete(); } if (recursive) foreach (DirectoryInfo child in di.GetDirectories()) { child.Delete(searchParttern, recursive); } } }