private void button5_Click(object sender, EventArgs e) { try { if (txtDecodeImageLocation.Text.Length > 0) { TP_File file = TP_Stenography.DecodeImage((Bitmap)Bitmap.FromFile(txtDecodeImageLocation.Text), txtDecodeKey.Text); saveFileDialog2.FileName = file.GetFileName(); DialogResult d = saveFileDialog2.ShowDialog(); if (d == DialogResult.OK) { file.Save(saveFileDialog2.FileName); } MessageBox.Show("File Extracted!", "2pix", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("There was an error extracting a file from this image.\nPossbile causes include:\n\n" + " - Invalid decryption key\n - Image does not contain any hidden files\n - Image was corrupted", "2pix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { try { string fileName = textBox1.Text; string key = textBox2.Text; string dest = fileName.Substring(0, fileName.LastIndexOf("\\")) + "\\"; if (File.Exists(fileName)) { TP_File file = TP_Stenography.DecodeImage((Bitmap)Bitmap.FromFile(fileName), key); // Get the original file name, but don't overwrite anything string name = dest + file.GetFileName(); if (File.Exists(name)) { name = dest + "2pix_" + file.GetFileName(); } file.Save(name); } MessageBox.Show("The file was extracted!", "2pix", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch { MessageBox.Show("There was an error extracting a file from this image.\nPossbile causes include:\n\n" + " - Invalid decryption key\n - Image does not contain any hidden files\n - Image was corrupted", "2pix", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }