public async void CalcMultiFiles(string path) { this.Width = 1150; FilesCryptInfo filesCryptInfo = new FilesCryptInfo(); if (this.checkBoxMD5.IsChecked == true) { await Task.Run(() => { filesCryptInfo.md5 = FilesCryptography.GetFileMD5(path); }); } if (this.checkBoxSHA1.IsChecked == true) { await Task.Run(() => { filesCryptInfo.sha1 = FilesCryptography.GetFileSHA1(path); }); } if (this.checkBoxSHA256.IsChecked == true) { await Task.Run(() => { filesCryptInfo.sha256 = FilesCryptography.GetFileSHA256(path); }); } filesCryptInfo.path = path; GlobalVar.listFilesCryptInfos.Add(filesCryptInfo); this.folderResult.AppendText(filesCryptInfo.path + "\n"); if (this.checkBoxMD5.IsChecked == true) { this.folderResult.AppendText("MD5: " + filesCryptInfo.md5 + "\n"); } if (this.checkBoxMD5.IsChecked == true) { this.folderResult.AppendText("SHA1: " + filesCryptInfo.sha1 + "\n"); } if (this.checkBoxMD5.IsChecked == true) { this.folderResult.AppendText("SHA256: " + filesCryptInfo.sha256 + "\n"); } this.folderResult.AppendText("----------------------------------------------------------------------------------------\n"); this.folderResult.ScrollToEnd(); }
public async void CalcFolderCrypt(string folderPath) { DirectoryInfo directoryInfo = new DirectoryInfo(folderPath); if (!directoryInfo.Exists) { return; } FileSystemInfo[] fileSystemInfos = directoryInfo.GetFileSystemInfos(); foreach (FileSystemInfo item in fileSystemInfos) { FilesCryptInfo filesCryptInfo = new FilesCryptInfo(); FileInfo fileInfo = item as FileInfo; if (fileInfo != null) { filesCryptInfo.name = fileInfo.Name; filesCryptInfo.path = Convert.ToString(new FileInfo(fileInfo.DirectoryName + "\\" + fileInfo.Name)); if (this.checkBoxMD5.IsChecked == true) { await Task.Run(() => { filesCryptInfo.md5 = FilesCryptography.GetFileMD5(filesCryptInfo.path); }); } if (this.checkBoxSHA1.IsChecked == true) { await Task.Run(() => { filesCryptInfo.sha1 = FilesCryptography.GetFileSHA1(filesCryptInfo.path); }); } if (this.checkBoxSHA256.IsChecked == true) { await Task.Run(() => { filesCryptInfo.sha256 = FilesCryptography.GetFileSHA256(filesCryptInfo.path); }); } GlobalVar.listFilesCryptInfos.Add(filesCryptInfo); this.folderResult.AppendText(filesCryptInfo.path + "\n"); if (this.checkBoxMD5.IsChecked == true) { this.folderResult.AppendText("MD5: " + filesCryptInfo.md5 + "\n"); } if (this.checkBoxMD5.IsChecked == true) { this.folderResult.AppendText("SHA1: " + filesCryptInfo.sha1 + "\n"); } if (this.checkBoxMD5.IsChecked == true) { this.folderResult.AppendText("SHA256: " + filesCryptInfo.sha256 + "\n"); } this.folderResult.AppendText("----------------------------------------------------------------------------------------\n"); this.folderResult.ScrollToEnd(); GlobalVar.cnt++; } else { string deepPath = folderPath + "\\" + item.ToString(); CalcFolderCrypt(deepPath); } } this.filecnt.Text = GlobalVar.cnt.ToString(); this.progressBar.IsIndeterminate = false; this.progressBar.Value = 100; GlobalVar.wheCalc = true; }