public static void FSHelperTest() { string dir = @"C:\Intel"; string outdir = @"C:\users\yabahman\desktop\"; Directory.SetCurrentDirectory(dir); //Setup const string longData = "asdjfahsdkjfhaksdjfhakjsdfhakjsdfhaskjdfhaskjdfhaksdjfhaskjdfhaskjdfhaskdjfhaskjdfhaskjdfhaskjdfhaskjdfhaskdjfhaskjfdh"; const string shortData = "a"; FileHelper.Touch("Shrunk.txt", longData); FileHelper.Touch("Grew.txt", shortData); FileHelper.Touch("Removed.txt"); File.Delete("Added.txt"); //Take snapshot 1 FSHelper fs1 = new FSHelper(dir); fs1.WriteToFile(outdir + @"outfile1.txt"); //Modify things FileHelper.Touch("Shrunk.txt", shortData); FileHelper.Touch("Grew.txt", longData); File.Delete("Removed.txt"); FileHelper.Touch("Added.txt"); //Take snapshot 2 FSHelper fs2 = new FSHelper(dir); fs2.WriteToFile(outdir + @"outfile2.txt"); //Compare data fs2.Diff(fs1); }
static void Main(string[] args) { if (args == null || args.Length <= 1) PrintUsage(); for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "/dump": goto case "-dump"; case "-dump": if (i + 1 >= args.Length) { PrintUsage(); throw new ArgumentException("-dump requires an additional argument"); } string rootDir = args[++i]; if (!File.Exists(rootDir) && !Directory.Exists(rootDir)) { PrintUsage(); throw new ArgumentException("rootDir was not a file or directory"); } string outfile = "dump.txt"; FSHelper fs = new FSHelper(rootDir); //fs.WriteToFile(outfile); fs.Print(); break; case "/diff": goto case "-diff"; case "-diff": if (i + 2 >= args.Length) { PrintUsage(); throw new ArgumentException("-diff requires +2 additional arguments"); } string oldDirOrDumpFile = args[++i]; if (!File.Exists(oldDirOrDumpFile) && !Directory.Exists(oldDirOrDumpFile)) { PrintUsage(); throw new ArgumentException("oldDirOrDumpFile was not a file or directory"); } string newDirOrDumpFile = args[++i]; if (!File.Exists(newDirOrDumpFile) && !Directory.Exists(newDirOrDumpFile)) { PrintUsage(); throw new ArgumentException("newDirOrDumpFile was not a file or directory"); } FSHelper oldFs = new FSHelper(oldDirOrDumpFile); FSHelper newFs = new FSHelper(newDirOrDumpFile); newFs.Diff(oldFs); break; default: PrintUsage(); break; } } #if (DEBUG) Console.WriteLine("\nAll Done!"); Console.ReadLine(); #endif }
public static void FSHelperTest2() { //string dir = @"C:\Users\"; string dir = @"C:\"; string outdir = @"C:\users\yabahman\desktop\"; Directory.SetCurrentDirectory(dir); //Take snapshot 1 FSHelper fs1 = new FSHelper(dir); fs1.WriteToFile(outdir + @"outfile1.txt"); //Take snapshot 2 FSHelper fs2 = new FSHelper(dir); fs2.WriteToFile(outdir + @"outfile2.txt"); //Compare data fs2.Diff(fs1); }