[收集]用asp.net调用dos命令~(通过cmd来执行)

来源:互联网 发布:我要上淘宝网买衣服 编辑:程序博客网 时间:2024/05/05 12:51
 

private void Button1_Click(object sender, System.EventArgs e)
  {
  
   CallExe( @"md c:/wxd" );   //这里用了@的话,可以不用写成C://wxd了
   }

  private void CallExe(string argm)
  {
   Process p = new Process();
   p.StartInfo.FileName = "cmd.exe";
   p.StartInfo.UseShellExecute = false;
   p.StartInfo.RedirectStandardInput = true;
   p.StartInfo.RedirectStandardOutput = true;
   p.StartInfo.RedirectStandardError = true;
   p.StartInfo.CreateNoWindow = true;

   p.Start();
   p.StandardInput.WriteLine(argm);
   p.StandardInput.WriteLine("exit");
   p.StandardOutput.ReadToEnd();
   p.Close();


  }

原创粉丝点击