public void GetHash(object sender, EventArgs e) { string path = view.getTextBox1 + "\\" + view.GetSetlistView.SelectedItems[0].Text; var file = new Forms.File(path); file.Accept(Cash); }
private void Rename(object sender, EventArgs e) { string d = view.getTextRename; string s = view.getTextBox1 + "\\" + view.GetSetlistView.SelectedItems[0].Text; string path = view.getTextBox1 + "\\" + view.GetSetlistView.SelectedItems[0].Text; var ext = new Forms.File(s).GetExtension(); if (s[s.Length - 1] == '\\') { s = s.Remove(s.Length - 1, 1); while (s[s.Length - 1] != '\\') { s = s.Remove(s.Length - 1, 1); } } else { while (s[s.Length - 1] != '\\') { s = s.Remove(s.Length - 1, 1); } } if (new Forms.File(path).Existing()) { new Forms.File(path).Move(s + d + ext); } else { new Forms.Folder(path).Move(s + d + ext); } }
public void Visit(Forms.File f) { string wat = f.GetTextFromFile(); wat = Decrypt(wat); var someStream = new Forms.File(f.GetFullName() + "crypt.txt").Create(); byte[] info = new UTF8Encoding(true).GetBytes(wat); someStream.Write(info, 0, info.Length); f.Delete(); }
public void Visit(Forms.File f) { myNum = -myNum; string wat = f.GetTextFromFile(); wat = Encryption(wat); var someStream = new Forms.File(f.GetFullName().Remove(f.GetFullName().Length - 5, 5) + ".txt").Create(); byte[] info = new UTF8Encoding(true).GetBytes(wat); someStream.Write(info, 0, info.Length); f.Delete(); }
public void Visit(Forms.Folder f) { string[] mas = Forms.Folder.Get_ALL_Files_From_All_Inner_Dir(f.GetFullName()); string dano = ""; foreach (string i in mas) { string s = new Forms.File(i).GetTextFromFile(); dano += s; } string hashed = MD5.CreateMD5(dano); MessageBox.Show(hashed); }
private void Decrypt(object sender, EventArgs e) { if (view.GetSetlistView.SelectedItems.Count > 0) { if (view.GetSetlistView.SelectedItems[0].Tag.ToString() == "file") { Forms.File m = new Forms.File(view.getTextBox1 + "\\" + view.GetSetlistView.SelectedItems[0].Text); CesarEncrypt.setKey(int.Parse(view.getTextCryptBox)); m.Accept(CesarEncrypt); } else { Forms.Folder m = new Forms.Folder(view.getTextBox1 + "\\" + view.GetSetlistView.SelectedItems[0].Text); CesarEncrypt.setKey(int.Parse(view.getTextCryptBox)); m.Accept(CesarEncrypt); } } }
public void Visit(Forms.File f) { string hashed = MD5.CreateMD5(f.GetTextFromFile()); MessageBox.Show(hashed); }
}//Копирование каталога со всеми файлами. public void Stat(object sender, EventArgs e) { string path = view.getTextBox1 + "\\" + view.GetSetlistView.SelectedItems[0].Text; if (new Forms.File(path).Existing()) { try { var WordsLength = Int16.Parse(view.getLengthofWord); string Final = ""; var CountLines = 0; var CountUnic = 0; Stopwatch stopwatch = Stopwatch.StartNew(); Task taskLines = Task.Run(() => { using (var reader = new Forms.File("").Open_Text(path)) { while (reader.ReadLine() != null) { CountLines++; } } Final += "Количество строк: " + CountLines + "\n"; }); Task taskWords = Task.Run(() => { int counter = 1; byte[] bytesInText = new Forms.File("").Read_All_Bytes(path); string ChangedTextInFile = Encoding.Default.GetString(bytesInText).ToLower().Replace(",", "").Replace(".", "").Replace("(", "").Replace(")", "").Replace("-", ""); string[] Words = ChangedTextInFile.Split(); Final += "Количество слов: " + Words.Length + "\n"; CountUnic = (from word in Words.AsParallel() select word).Distinct().Count(); Final += "Количество уникальных слов: " + CountUnic + "\n"; var WordGroups = Words.GroupBy(s => s).Where(g => g.Count() > 1).OrderByDescending(g => g.Count()).Select(g => g.Key).ToList(); WordGroups.Remove(""); var ListWords = (from word in WordGroups where word.Length > WordsLength select word); var topTenWords = ListWords.Take(10); Final += "Самые популярные слова длины большей " + WordsLength + ":\n"; foreach (var word in topTenWords) { Final += counter + ": " + word + "\n"; counter++; } }); var finalTask = Task.Factory.ContinueWhenAll(new Task[] { taskLines, taskWords }, ant => { stopwatch.Stop(); Final += "Время работы: " + stopwatch.Elapsed.TotalSeconds + " секунд."; MessageBox.Show(Final, "Текстовая статистика.", MessageBoxButtons.OK); }); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Может быть выбран только текстовый файл.", "Предупреждение.", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }//Статистика текстового файла.