有人知道吗?
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();
我是这样执行的,但是一直死在那里~~~

解决方案 »

  1.   

    // 一行就够了:
    System.Diagnostics.Process.Start("ftp", "-s:c:\request.txt"); 
      

  2.   

    // 一行就够了:
    System.Diagnostics.Process.Start("ftp", "-s:c:\\request.txt"); 
      

  3.   

    注意\在C#字符串中的写法,要写成:"-s:c:\\request.txt"或:@"-s:c:\request.txt"
      

  4.   

    Process p = new Process(); 
                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(); 
      

  5.   

    简单的说dos命令分两种:
      一种是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");
      

  6.   

    参考使用C#调用外部Ping命令获取网络连接情况
    http://blog.csdn.net/zhzuo/archive/2004/03/21/22024.aspx
      

  7.   

    学习中,我有个问题,怎样调用带有参数的bat文件,参数为具体文件名如c:\test\test.txt,谢谢
    bat文件为上传到ftp,我在doc里可以执行,但在代码里就是没传上去