public void DeleteDirectory(DirectoryInfo dir, string trg) { foreach (DirectoryInfo sub in dir.GetDirectories()) { if (sub.Name.Equals(trg)) { foreach (FileInfo file in sub.GetFiles()) file.Delete(); sub.Delete(); } else DeleteDirectory(sub, trg); } }
Monday, July 19, 2010
Deleting a Directory and All Its Contents - C#
Quick code I wrote the delete all directories named, trg, within the source directory, src.
Labels:
C#,
C# Sample Code
0 comments:
Post a Comment