private void SaveSelectionToFile(long start, long length) { using (SaveFileDialog dlg = new SaveFileDialog()) { dlg.Filter = "All Files (*.*)|*.*"; if (dlg.ShowDialog(this) == DialogResult.OK) { byte[] data = new byte[length]; for (long i = 0; i < length; ++i) { data[i] = _prov.ReadByte(i + start); } try { File.WriteAllBytes(dlg.FileName, data); } catch (IOException ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void saveToFileToolStripMenuItem_Click(object sender, EventArgs e) { long start = hexBox.SelectionStart; long length = hexBox.SelectionLength; if (length > 0) { using (SaveFileDialog dlg = new SaveFileDialog()) { dlg.Filter = "All Files (*.*)|*.*"; if (dlg.ShowDialog(this) == DialogResult.OK) { byte[] data = new byte[length]; for (long i = 0; i < length; ++i) { data[i] = _prov.ReadByte(i + start); } try { File.WriteAllBytes(dlg.FileName, data); } catch (IOException ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }