private void extract_Click(object sender, EventArgs e) { FileStream readStream; try { readStream = new FileStream(filename, FileMode.Open); } catch (IOException) { MessageBox.Show("Opening file error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string result = LSB.ExtractText(new Bitmap(readStream)); readStream.Close(); extractedMessage.Text = result; filename = ""; }
private void hide_Click(object sender, EventArgs e) { FileStream readStream; try { readStream = new FileStream(srcFilename, FileMode.Open); } catch (IOException) { MessageBox.Show("Opening file error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Bitmap result = LSB.HideText(hiddenMessage.Text, new Bitmap(readStream)); readStream.Close(); if (saveFileDialog.ShowDialog() == DialogResult.OK) { destFilename = saveFileDialog.FileName; } else { return; } FileStream writeStream; try { writeStream = new FileStream(destFilename, FileMode.Create); } catch (IOException) { MessageBox.Show("Opening file error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } result.Save(writeStream, System.Drawing.Imaging.ImageFormat.Bmp); writeStream.Close(); srcFilename = ""; destFilename = ""; }