internal static void ProcessFolder(string folder) { Output.Print(folder, Output.LevelInfo.Info); Output.Print("\tgetting files"); string[] files = System.IO.Directory.GetFiles(folder); Array.Sort(files); int savedHash = HashManager.Get(folder + "*"); int currentHash = HashManager.JoinHashes(files); if (savedHash == currentHash) { Output.Print("\t\tno change of files, skipping"); return; } foreach (var fileName in files) { ProcessFile(fileName); } files = System.IO.Directory.GetFiles(folder); currentHash = HashManager.JoinHashes(files); HashManager.Set(folder + "*", currentHash); }
public static void ProcessFolder(string folder) { Output.Print(folder, Output.LevelInfo.Info); Output.Print("\tgetting subfolders"); string[] folders = System.IO.Directory.GetDirectories(folder); int savedHash = HashManager.Get(folder); int currentHash = HashManager.JoinHashes(folders); if (savedHash == currentHash) { Output.Print("\t\tno change of subfolders, deleting temp and skipping"); DeleteTempFolders(folder); return; } Array.Sort(folders); bool hasSomeErrorOccured = false; for (int i = 0; i < folders.Length; i++) { try { string name; string fullTempName; PrepareNamesForFolder(folder, folders, i, out name, out fullTempName); Output.Print("\t" + name + " (updating location)"); ProcessFolderMoving(folders, i, fullTempName); } catch (Exception ex) { Output.Print("\t\t - error: " + ex.Message, Output.LevelInfo.Error); hasSomeErrorOccured = true; } } DeleteTempFolders(folder); folders = System.IO.Directory.GetDirectories(folder); if (!hasSomeErrorOccured) { currentHash = HashManager.JoinHashes(folders); HashManager.Set(folder, currentHash); } }