32位win7环境下C#操作CMD执行ftp会卡死,WIN10就可以正常运行求解决
在win7 32位系统的电脑上写了一个程序 通过调用cmd远程连接ftp ,一运行就卡死。
CMD手动输入FTP可以正常执行,就是不能用C#写的程序执行FTP,但是程序可以dir等其他本地操作命令。
代码如下:
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false; //关闭Shell的使用
p.StartInfo.RedirectStandardInput = true; //重定向标准输入
p.StartInfo.RedirectStandardOutput = true; //重定向标准输出
p.StartInfo.RedirectStandardError = true; //重定向错误输出
p.StartInfo.CreateNoWindow = true;//创建窗口 false是开启窗口
p.Start();
p.StandardInput.WriteLine("ftp");
p.StandardInput.WriteLine("bye");
p.StandardInput.WriteLine("exit");
p.StandardInput.AutoFlush = true;
StreamReader reader = p.StandardOutput;
p.WaitForExit();
p.Dispose();
我试过所有我能想到的办法,甚至包括重做系统,依然没有用,哪位大神能帮我解决下?