• 修改磁盘格式


    实现效果:

      

    知识运用:

      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();                                                //执行完退出
            }
    

      

  • 相关阅读:
    Java面向对象编程 -1.3
    Java面向对象编程 -1.2
    Java面向对象编程 -1
    Java基础 -5.3
    Java基础 -5.2
    oracle 新建用户
    js密码的匹配正则
    oracle导入和导出和授权
    oracle存储过程语法
    java.lang.NumberFormatException: For input string: "26.0"
  • 原文地址:https://www.cnblogs.com/feiyucha/p/10305821.html
Copyright © 2020-2023  润新知