コード例 #1
0
        private void ButtonEraseMBRClick(object sender, EventArgs e)
        {
            if (comboBoxDrives.SelectedIndex < 0)
            {
                return;
            }

            var drive = (string)comboBoxDrives.SelectedItem;

            var success = false;

            try
            {
                success = _disk.EraseMBR(drive);
            }
            catch (Exception ex)
            {
                success = false;
                toolStripStatusLabel1.Text = ex.Message;
            }

            if (!success && !_disk.IsCancelling)
            {
                MessageBoxEx.Show("Problem writing to disk. Is it write-protected?", "Write Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBoxEx.Show("MBR erased. Please remove and reinsert to format", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }