public static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Syntax: Redactr <Directory Name> <Word To Redact>"); return; } Redactr r = new Redactr(); r.TraverseDirectory(args[0], args[1]); while (Redactr.tasks.Any(t => !t.IsCompleted)) { } // Spin-Wait }
public void TraverseDirectory(string dn, string rw) { IDirectoryInfo dirInfo = this.fileSystem.DirectoryInfo.FromDirectoryName(dn); foreach (IDirectoryInfo di in dirInfo.EnumerateDirectories()) { Redactr r = new Redactr(this.fileSystem); r.TraverseDirectory(di.FullName, rw); } foreach (IFileInfo fi in dirInfo.EnumerateFiles()) { tasks.Add(Task.Factory.StartNew(() => { Redactor.Redact(new RedactData(this.fileSystem, fi.FullName, rw, '*')); })); } }