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

c#中重定向windows控制臺程序的輸出信息

系統(tǒng) 2270 0

這個問題來自論壇提問,答案如下.這只是一個簡單的ipconfig命令.如果是復(fù)雜的,比如oracle的exp之類的命令,能在調(diào)用的時候顯示出來,還是相當(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控制臺程序的輸出信息


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

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

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

【本文對您有幫助就好】

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

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 时尚| 广河县| 岐山县| 广宁县| 铁力市| 嘉兴市| 余姚市| 赤峰市| 虎林市| 农安县| 琼海市| 宜兴市| 长治县| 雷波县| 铜鼓县| 托里县| 宜章县| 星座| 岳池县| 富平县| 正安县| 江源县| 隆昌县| 吐鲁番市| 灯塔市| 安岳县| 高唐县| 黔西县| 高台县| 太谷县| 阳西县| 沾益县| 淮滨县| 河池市| 梓潼县| 苍山县| 东宁县| 名山县| 龙泉市| 营口市| 宁陕县|