private void AddHash_btn_Click(object sender, EventArgs e) { var name = Path.GetFileName(FilePathtxt.Text); var hash = HashFiletxt.Text; var hashObj = new HashFileClass() { Name = name, Hash = hash }; HashFileListClass.HashList.Add(hashObj); SetDataGridSource(); }
private void SaveHashFileToList(HashFileClass hash = null) { try { //if (HashFileListClass.HashList.FirstOrDefault(x => string.Compare(x.Hash, hash.Hash) == 0) == null) //{ // HashFileListClass.HashList.Add(hash); //Sync Hash List var stringJson = Newtonsoft.Json.JsonConvert.SerializeObject(HashFileListClass.HashList); File.WriteAllText(Directory.GetCurrentDirectory() + @"\PermissibleFile.txt", stringJson, Encoding.UTF8); var killsuspend = 0; if (ProcessSkipKillRadio_btn.Checked) { killsuspend = 1; } if (ProcessSkipSuspendRadio_btn.Checked) { killsuspend = 2; } ProcessToSkipList.KillOrSuspendList.Remove(ProcessToSkipList.KillOrSuspendList.FirstOrDefault(x => x.EventName == EventName.Process)); ProcessToSkipList.KillOrSuspendList.Add(new KillOrSuspendList() { KillOrSuspend = killsuspend, EventName = EventName.Process }); var stringJson_p = Newtonsoft.Json.JsonConvert.SerializeObject(new ProcessSkipToSave() { ProcessSkipList = ProcessToSkipList.ProcessNames, KillOrSuspend = ProcessToSkipList.KillOrSuspendList }); File.WriteAllText(Directory.GetCurrentDirectory() + @"\ProcessToSkip.txt", stringJson_p, Encoding.UTF8); MessageBox.Show("تنطیمات با موفقیت ذخیره شد"); //} //else // MessageBox.Show("این هش فایل قبلا ثبت شده است."); } catch (Exception ex) { MessageBox.Show(ex.Message); } }