熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> ASP編程 >> 正文

C# 中啟動進程的三種方法

2022-06-13   來源: ASP編程 

  啟動子進程不等待子進程結束

private void simpleRun_Click(object sender SystemEventArgs e)
{ SystemDiagnosticsProcessStart(@C:listfilesbat);
}


  啟動子進程等待子進程結束並獲得輸出

private void runSyncAndGetResults_Click(object sender SystemEventArgs e)
{
  SystemDiagnosticsProcessStartInfo psi = new SystemDiagnosticsProcessStartInfo(@C:listfilesbat);
  psiRedirectStandardOutput = true;
  psiWindowStyle = SystemDiagnosticsProcessWindowStyleHidden;
  psiUseShellExecute = false;
  SystemDiagnosticsProcess listFiles;
  listFiles = SystemDiagnosticsProcessStart(psi);
  SystemIOStreamReader myOutput = listFilesStandardOutput;
  listFilesWaitForExit();
  
  if (listFilesHasExited) 
  { 
    string output = myOutputReadToEnd(); 
    thisprocessResultsText = output;
  }
}
使用默認的浏覽器打開URL
private void launchURL_Click(object sender SystemEventArgs e)
{
  string targetURL = @http://wwwduncanmackenzienet;
  SystemDiagnosticsProcessStart(targetURL);
}


From:http://tw.wingwit.com/Article/program/ASP/201311/21896.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.