private void DecryptBtn_Click(object sender, EventArgs e) { _watch.Reset(); if (!File.Exists(FilePathTxt.Text)) { MessageBox.Show(Resources.FileNotFoundMessage); return; } ChangeStates(false); StatusLbl.Text = Resources.DecryptionInProgressMessage; var filePath = Path.GetDirectoryName(FilePathTxt.Text) + $"\\decrypted-{DateTime.Now.Ticks}.{FileExtensionBx.Text}"; Task.Run(() => { _watch.Start(); using (BinaryWriter bw = new BinaryWriter(File.Create(filePath))) bw.Write(ICrypt.BmpDecrypt((Bitmap)Image.FromFile(FilePathTxt.Text))); _watch.Stop(); Invoke(new MethodInvoker(() => { ChangeStates(true); StatusLbl.Text = string.Format(Resources.DecryptionSuccessMessage, _watch.ElapsedMilliseconds); })); }); }