问题:就是执行到WaitForExit 这里执行不下了,错了也给应该有一个反馈吧。程序的下载地址:正在上传,,,,先看代码,把,,,StringBuilder sb = new StringBuilder();
public Form1()
{
InitializeComponent();
string apppath = System.AppDomain.CurrentDomain.BaseDirectory;
string extArguments = "";
string pfdFilePath = apppath + "a.pdf";
string swfFilePath = apppath + "b.swf";
Process process = new Process(); //创建进程对象 ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = apppath + "pdf2swf.exe";
startInfo.Arguments = pfdFilePath + " -s flashversion=9 -o " + swfFilePath + extArguments; startInfo.UseShellExecute = false; //不使用系统外壳程序启动
startInfo.RedirectStandardInput = true; //不重定向输入
startInfo.RedirectStandardOutput = true; //重定向输出
startInfo.CreateNoWindow = true; //不创建窗口
startInfo.RedirectStandardError = true; process.StartInfo = startInfo; process.Start();
process.BeginOutputReadLine();
process.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(SortOutputHandler);
process.WaitForExit(); }
void SortOutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
if (!String.IsNullOrEmpty(outLine.Data))
{
sb.Append(Environment.NewLine + "[" + numOutputLines.ToString() + "] - " + outLine.Data);
}
}
public Form1()
{
InitializeComponent();
string apppath = System.AppDomain.CurrentDomain.BaseDirectory;
string extArguments = "";
string pfdFilePath = apppath + "a.pdf";
string swfFilePath = apppath + "b.swf";
Process process = new Process(); //创建进程对象 ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = apppath + "pdf2swf.exe";
startInfo.Arguments = pfdFilePath + " -s flashversion=9 -o " + swfFilePath + extArguments; startInfo.UseShellExecute = false; //不使用系统外壳程序启动
startInfo.RedirectStandardInput = true; //不重定向输入
startInfo.RedirectStandardOutput = true; //重定向输出
startInfo.CreateNoWindow = true; //不创建窗口
startInfo.RedirectStandardError = true; process.StartInfo = startInfo; process.Start();
process.BeginOutputReadLine();
process.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(SortOutputHandler);
process.WaitForExit(); }
void SortOutputHandler(object sendingProcess, DataReceivedEventArgs outLine)
{
if (!String.IsNullOrEmpty(outLine.Data))
{
sb.Append(Environment.NewLine + "[" + numOutputLines.ToString() + "] - " + outLine.Data);
}
}
{
string apppath = System.AppDomain.CurrentDomain.BaseDirectory;
Process process = new Process(); //创建进程对象
ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "notepad.exe";
startInfo.Arguments = "c:\\1.txt"; startInfo.UseShellExecute = false; //不使用系统外壳程序启动
startInfo.RedirectStandardInput = true; //不重定向输入
startInfo.RedirectStandardOutput = true; //重定向输出
startInfo.CreateNoWindow = true; //不创建窗口
startInfo.RedirectStandardError = true; process.StartInfo = startInfo;
process.Start();
process.BeginOutputReadLine();
process.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(SortOutputHandler);
process.WaitForExit();
MessageBox.Show("wait for exit"); }
http://msdn.microsoft.com/zh-cn/library/vstudio/fb4aw7b8(v=vs.100).aspx