在线等。。。急急急!!!

killyourdidi killyourdidi 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
读取*.exe的输出显示到文本:
{
...
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c " + "\".....*.exe\"";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
reader = p.StandardOutput;
line = reader.ReadLine();


//1秒钟执行一次
time1 = new System.Timers.Timer();
time1.Enabled = true;
time1.Interval = 1000D;
time1.Elapsed+=new System.Timers.ElapsedEventHandler(time1_Elapsed);
...
}
...
private void time1_Elapsed(object sender, ElapsedEventArgs e)
{
while ((line != " Running:\n")&& (!reader.EndOfStream))
{
printInfo.AppendText(line);
line = reader.ReadLine();
}
if (line == " Running:\n")
{
printInfo.AppendText(line);
line = reader.ReadLine();
.........
}
if (reader.EndOfStream)///////结果没有显示完就执行了这句,求解????????
{
printInfo.AppendText(line);
time1.Enabled = false;
}
}
...全文
评论 8
收藏 已收藏
分享
返回顶部
killyourdidi
C# 111,130 成员 642,541 内容