卡住了,关于进度条的,请大神指点
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
namespace ccc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process mycmd = new Process();
mycmd.StartInfo.FileName = "cmd.exe";//设置程序名称
mycmd.StartInfo.Arguments = "/c" + " dir /b /s /ad " + """ + xph.Text;
mycmd.StartInfo.UseShellExecute = false;//关闭SHELL的使用
mycmd.StartInfo.CreateNoWindow = true; //关闭窗口
mycmd.StartInfo.RedirectStandardInput = true;//获取或设置一个值,该值指示应用程序的输入是否从 Process.StandardInput 流中读取
mycmd.StartInfo.RedirectStandardOutput = true;//获取或设置一个值,该值指示是否将应用程序的输出写入 Process.StandardOutput 流中。
mycmd.StartInfo.RedirectStandardError = true;//获取或设置一个值,该值指示是否将应用程序的错误输出写入 Process.StandardError 流中。
mycmd.Start();
this.jieguo.Text = mycmd.StandardOutput.ReadToEnd();
mycmd.Close();
}
private void button2_Click(object sender, EventArgs e)
{
this.fph.ShowDialog();
this.xph.Text = fph.SelectedPath;
}
private void button3_Click(object sender, EventArgs e)
{
this.jieguo.Text = "";
}
}
}
另外加了一个progressBar控件,用来显示运行过程
这个程序的意思是 执行一个DOS命令,(都知道有些DOS命令比较耗时间,有时候就像假死一样)在执行的过程中递增进度条,等执行完了就100%,尝试过好几种办法,没有成功,只能求助各位大神了
另外,textbox.text属性输出的结果总是在第一行,可以往下拉,请问怎么让它结果是最后一行,或者干脆运行过程中同步显示DOS在执行中的内容,不知道大神们明白不明白我说的意思
再次感谢大神们了,谢谢了,希望能帮忙
[解决办法]
Application.DoEvents();//让程序执行进度条的前进动作