1. 程式人生 > >修改磁盤格式

修改磁盤格式

creat rect eno win com form file owin csharp

實現效果:

  技術分享圖片

知識運用:

  Dos命令: "/c convert 盤符 /fs:ntfs"

實現代碼:

        private void button1_Click(object sender, EventArgs e)
        {
            DriveInfo Dinfo = new DriveInfo(comboBox1.Text);
            textBox1.Text = Dinfo.DriveFormat;
            if (textBox1.Text == "NTFS")
                button2.Enabled = false;
            else if (textBox1.Text == "FAT32")
                button2.Enabled = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
            myProcess.StartInfo.FileName = "cmd.exe";
            myProcess.StartInfo.Arguments = "/c convert "+textBox1.Text+" /fs:ntfs";
            myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;    //隱藏窗口
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.RedirectStandardError = true;
            myProcess.StartInfo.RedirectStandardInput = true;
            myProcess.StartInfo.RedirectStandardOutput = true;
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.Start();
            myProcess.WaitForExit();                                                //執行完退出
        }

  

修改磁盤格式