void LoadFile(string path, bool OpenWithValidation) { PasswordsGrd.Rows.Clear(); try { file = PasswordsFile.Load(path); bool passwordIsOk = false; MasterPasswordInput_frm frm = new MasterPasswordInput_frm(file.MasterPassword); if (OpenWithValidation) { passwordIsOk = frm.ShowDialog() == DialogResult.OK; } if ((OpenWithValidation && passwordIsOk) || OpenWithValidation == false) { DisplayPasswords(file.Passwords); } else { Close(); } } catch { var result = MessageBox.Show("Faild To Open Passwords File.Do You Want To ReCreate It?", "Open Failed", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { CreateFileFrm frm2 = new CreateFileFrm(path); frm2.ShowDialog(); } } }
private void ExportBtn_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Passwords File|*.mps"; if (sfd.ShowDialog() == DialogResult.OK) { if (PasswordsGrd.SelectedRows.Count > 0) { //Create New File To Export To PasswordsFile newfile = new PasswordsFile(); newfile.Passwords = new List <Password>(); foreach (DataGridViewRow row in PasswordsGrd.SelectedRows) { Password password = new Password() { password = row.Cells["Password_col"].Value.ToString(), UserName = row.Cells["UserName_col"].Value.ToString(), LNK = row.Cells["Link_col"].Value.ToString(), Details = row.Cells["details_col"].Value.ToString(), }; newfile.Passwords.Add(password); } //Save With The Same MasterPassword Or Create New var result = MessageBox.Show("Do You Want To Set Master Password?", "new MasterPassword", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { CreateFileFrm frm = new CreateFileFrm(sfd.FileName); if (frm.ShowDialog() == DialogResult.OK) { newfile.MasterPassword = frm.Password; } else { MessageBox.Show("You Have Canceld new Password Creation.File Will Be saved With Current Master Password."); newfile.MasterPassword = file.MasterPassword; } } else { newfile.MasterPassword = file.MasterPassword; } newfile.Save(sfd.FileName); } else { file.Save(sfd.FileName); } MessageBox.Show("passwords Was Successfully Exported"); } }
public Password_AE(string password, string path) { InitializeComponent(); this.path = path; Passwordtxt.Text = password; if (!System.IO.File.Exists(path)) { CreateFileFrm frm = new CreateFileFrm(path); DialogResult result = frm.ShowDialog(); if (result != DialogResult.OK) { MessageBox.Show("File Creation Was Canceld."); this.Close(); } } }