问题描述
stringshellName=@"C:winscpWinSCP.com";stringfromFilePD=@"FILE02.zip";stringtoFilePD=@"incoming/proccessed_data/FILE02.zip";stringfromFileSD=@"FILE01.zip";stringtoFileSD=@"incoming/ship_data/FILE01.zip";stringfromFileCAB=@"FILE03.zip";stringtoFileCAB=@"incoming/commodity_data/FILE03.zip";ProcessCommandLine=newProcess();CommandLine.StartInfo.FileName=shellName;CommandLine.StartInfo.UseShellExecute=false;CommandLine.StartInfo.RedirectStandardInput=true;CommandLine.StartInfo.RedirectStandardOutput=true;CommandLine.StartInfo.CreateNoWindow=true;CommandLine.Start();//username用户名targetAddressIP地址portNumber端口号CommandLine.StandardInput.WriteLine("opensftp://<地址>:22");CommandLine.StandardInput.WriteLine(“<账号>");CommandLine.StandardInput.WriteLine(”<密码>");//CommandLine.StandardInput.WriteLine("optionconfirmoff");CommandLine.StandardInput.WriteLine("PUT"+""+fromFileSD+""+toFileSD);CommandLine.StandardInput.WriteLine("Retry");CommandLine.StandardInput.WriteLine("PUT"+""+fromFilePD+""+toFilePD);CommandLine.StandardInput.WriteLine("Retry");CommandLine.StandardInput.WriteLine("PUT"+""+fromFileCAB+""+toFileCAB);CommandLine.StandardInput.WriteLine("Retry");//上传文件到sftp服务器//stringcommand="send"+fromFilePD+""+toFilePD;//stringcommand1="send"+fromFileSD+""+toFileSD;//fromFile要传送的文件路径本地的绝对路径toFile服务器上保存文件的路径相对路径CommandLine.StandardOutput.DiscardBufferedData();//CommandLine.StandardInput.WriteLine(command);stringresult=CommandLine.StandardOutput.ReadLine();