/// <summary> /// Read from removable media to file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonReadClick(object sender, EventArgs e) { if (comboBoxDrives.SelectedIndex < 0) { return; } var drive = (string)comboBoxDrives.SelectedItem; if (string.IsNullOrEmpty(textBoxFileName.Text)) { ChooseFile(); } DisableButtons(true); try { _disk.ReadDrive(drive, textBoxFileName.Text, _eCompType, checkBoxUseMBR.Checked); } catch (Exception ex) { toolStripStatusLabel1.Text = ex.Message; } EnableButtons(); }
/// <summary> /// Select a file for read/write from/to removable media /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void ButtonChooseFileClick(object sender, EventArgs e) //{ // ChooseFile(); //} /// <summary> /// Read from removable media to file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonReadClick(object sender, EventArgs e) { if (checkedListBoxDrives.CheckedItems.Count != 1) { MessageBox.Show( Resources.MainForm_ButtonReadClick_You_can_read_from_only_one_drive_at_a_time, Resources.MainForm_ButtonReadClick_____WARNING____, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var drive = (string)checkedListBoxDrives.CheckedItems[0]; ClearLayoutPanels(); if (ChooseFileToRead() == false) { return; } var filePath = lastDirectoryUsed + "//" + lastFileUsed; DisableButtons(true); Task.Factory.StartNew(() => { DiskAccesses.Clear(); _disks.Clear(); var diskAccess = NewDiskAccess(); var disk = new Disk(diskAccess); Thread.CurrentThread.CurrentUICulture = CurrentLocale; SendProgressToUI(disk); DiskAccesses.Add(diskAccess); _disks.Add(disk); var res = false; try { res = disk.ReadDrive(drive, filePath, _eCompType, unmountDrivesToolStripMenuItem.Checked); } catch (Exception ex) { Invoke(new Action(() => MessageBox.Show(ex.Message, @"Exception at ReadDrive", MessageBoxButtons.OK, MessageBoxIcon.Error))); } if (!res && !disk.IsCancelling) { Invoke(new Action(() => MessageBox.Show(Resources.MainForm_ButtonReadClick_Problem_with_reading_from_disk_, Resources.MainForm_ButtonReadClick_Read_Error, MessageBoxButtons.OK, MessageBoxIcon.Error))); } Invoke((MethodInvoker)EnableButtons); if (res) { Invoke((MethodInvoker)EndInfo); } }); }
/// <summary> /// Select a file for read/write from/to removable media /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void ButtonChooseFileClick(object sender, EventArgs e) //{ // ChooseFile(); //} /// <summary> /// Read from removable media to file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonReadClick(object sender, EventArgs e) { if (checkedListBoxDrives.CheckedItems.Count != 1) { MessageBox.Show( Resources.MainForm_ButtonReadClick_You_can_read_from_only_one_drive_at_a_time, Resources.MainForm_ButtonReadClick_____WARNING____, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var drive = (string)checkedListBoxDrives.CheckedItems[0]; ClearLayoutPanels(); if (ChooseFileToRead() == false) return; var filePath = lastDirectoryUsed + "//" + lastFileUsed; DisableButtons(true); Task.Factory.StartNew(() => { DiskAccesses.Clear(); _disks.Clear(); var diskAccess = NewDiskAccess(); var disk = new Disk(diskAccess); Thread.CurrentThread.CurrentUICulture = CurrentLocale; SendProgressToUI(disk); DiskAccesses.Add(diskAccess); _disks.Add(disk); var res = false; try { res = disk.ReadDrive(drive, filePath, _eCompType, unmountDrivesToolStripMenuItem.Checked); } catch (Exception ex) { Invoke(new Action(() => MessageBox.Show(ex.Message, @"Exception at ReadDrive", MessageBoxButtons.OK, MessageBoxIcon.Error))); } if (!res && !disk.IsCancelling) { Invoke(new Action ( () => MessageBox.Show(Resources.MainForm_ButtonReadClick_Problem_with_reading_from_disk_, Resources.MainForm_ButtonReadClick_Read_Error, MessageBoxButtons.OK, MessageBoxIcon.Error))); } Invoke((MethodInvoker) EnableButtons); if (res) Invoke((MethodInvoker) EndInfo); }); }