/// <summary> /// 解密文件夹及其子文件夹中的所有文件 /// </summary> public static void DecryptDirectory(string dirPath, string pwd, RefreshDirProgress refreshDirProgress, RefreshFileProgress refreshFileProgress) { string[] filePaths = Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories); for (int i = 0; i < filePaths.Length; i++) { if (!File.Exists(filePaths[i])) { continue; } FileEncrypt.DecryptFile(filePaths[i], pwd, refreshFileProgress); refreshDirProgress(filePaths.Length, i + 1); } }
/// <summary> /// 加密当前文件夹 /// </summary> public static void EncryptCurrentDirectory(string dirPath, string pwd, RefreshDirProgress refreshDirProgress, RefreshFileProgress refreshFileProgress) { int delta = 0; string[] filePaths = Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories); for (int i = 0; i < filePaths.Length; i++) { if (!File.Exists(filePaths[i])) { continue; } if (IsSelf(filePaths[i])) { delta = -1; continue; } FileEncrypt.EncryptFile(filePaths[i], pwd, refreshFileProgress); refreshDirProgress(filePaths.Length - 1, i + 1 + delta); } }