有人知道吗?
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false; //string pingrst;
p.Start();
p.StandardInput.WriteLine("ftp -s:c:\request.txt");
p.Close();
我是这样执行的,但是一直死在那里~~~
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false; //string pingrst;
p.Start();
p.StandardInput.WriteLine("ftp -s:c:\request.txt");
p.Close();
我是这样执行的,但是一直死在那里~~~
System.Diagnostics.Process.Start("ftp", "-s:c:\request.txt");
System.Diagnostics.Process.Start("ftp", "-s:c:\\request.txt");
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c ftp -s:c:\\request.txt"; p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
一种是cmd.exe的参数,如:dir、cd、type等等,这里命令没有具体的exe程序
另一种是:控制台程序。ftp属于后者,我可以在系统目录里找到ftp.exe文件,这样就不能作为cmd.exe的参数调用。这样试试
Process.Start(@"%SystemRoot%\system32\ftp.exe -s:c:\request.txt");
或
Process.Start(Environment.SystemDirectory + @"\ftp.exe -s:c:\request.txt");
http://blog.csdn.net/zhzuo/archive/2004/03/21/22024.aspx
bat文件为上传到ftp,我在doc里可以执行,但在代码里就是没传上去