日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

c#中重定向windows控制臺(tái)程序的輸出信息

系統(tǒng) 2434 0

這個(gè)問(wèn)題來(lái)自論壇提問(wèn),答案如下.這只是一個(gè)簡(jiǎn)單的ipconfig命令.如果是復(fù)雜的,比如oracle的exp之類的命令,能在調(diào)用的時(shí)候顯示出來(lái),還是相當(dāng)酷的.

using System;
using System.Windows.Forms;

namespace WindowsApplication8
... {
public partial class Form1:Form
... {
public Form1()
... {
InitializeComponent();
}


delegate void dReadLine( string strLine);
private void excuteCommand( string strFile, string args,dReadLineonReadLine)
... {
System.Diagnostics.Processp
= new System.Diagnostics.Process();
p.StartInfo
= new System.Diagnostics.ProcessStartInfo();
p.StartInfo.FileName
= strFile;
p.StartInfo.Arguments
= args;
p.StartInfo.WindowStyle
= System.Diagnostics.ProcessWindowStyle.Hidden;
p.StartInfo.RedirectStandardOutput
= true ;
p.StartInfo.UseShellExecute
= false ;
p.StartInfo.CreateNoWindow
= true ;
p.Start();
System.IO.StreamReaderreader
= p.StandardOutput; // 截取輸出流
string line = reader.ReadLine(); // 每次讀取一行
while ( ! reader.EndOfStream)
... {
onReadLine(line);
line
= reader.ReadLine();
}

p.WaitForExit();
}


private void button1_Click( object sender,EventArgse)
... {
excuteCommand(
" ipconfig " , "" , new dReadLine(PrintMessage));
}

private void PrintMessage( string strLine)
... {
this .textBox1.Text += strLine + " " ;
}

}

}

c#中重定向windows控制臺(tái)程序的輸出信息


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 三台县| 林芝县| 双流县| 烟台市| 湾仔区| 常州市| 济源市| 含山县| 西乌珠穆沁旗| 象州县| 垦利县| 临西县| 壤塘县| 泉州市| 吉隆县| 苍山县| 长治县| 桂东县| 玛沁县| 聊城市| 石阡县| 离岛区| 永靖县| 芜湖县| 延津县| 佛冈县| 嘉黎县| 临沧市| 柳河县| 穆棱市| 临城县| 高尔夫| 德钦县| 宝兴县| 新邵县| 万全县| 尼玛县| 浑源县| 上林县| 甘肃省| 防城港市|