C# .net使用winscp将文件从windows移动到linux

C# .net使用winscp将文件从windows移动到linux,c#,.net,C#,.net,正在编写将文件从windows客户端移动到远程linux服务器的代码。 通过保持静态文件名,代码可以很好地执行,但在动态传递文件名时,代码并没有按预期工作。下面是代码,请建议。 谢谢 阿夫扎尔 通过使用winscp库和下面url中的代码解决了此问题 “代码无法按预期工作”-您能否详细说明发生了什么,以及您希望发生什么?它没有按预期使用相同的名称复制文件,例如:200.jpeg,作为传递的参数(文件名)。改为将文件命名为“log=C:UsersAdministratorDesktoptest.l

正在编写将文件从windows客户端移动到远程linux服务器的代码。 通过保持静态文件名,代码可以很好地执行,但在动态传递文件名时,代码并没有按预期工作。下面是代码,请建议。 谢谢 阿夫扎尔


通过使用winscp库和下面url中的代码解决了此问题


“代码无法按预期工作”-您能否详细说明发生了什么,以及您希望发生什么?它没有按预期使用相同的名称复制文件,例如:200.jpeg,作为传递的参数(文件名)。改为将文件命名为“log=C:UsersAdministratorDesktoptest.log”。事实并非如此,您指定了
log
参数,该参数指向
C:/Users/Administrator/Desktop/test.log
。因此,
test.log
文件不是您要复制的文件。感谢您的回复,请让我进一步澄清。如果我传递的静态文件名低于20.jpeg,代码如下@/command“”选项批处理打开“”选项确认关闭“”打开userx:pwdx@10.1.1.1“”“将C:\Mobile\Attachments\20.jpeg/tmp/”“/log=C:\Users\Administrator\Desktop\test.log”“退出”“,文件复制成功。同样,我希望动态传递文件名。
  var psi = new System.Diagnostics.ProcessStartInfo(@"c:\Program Files (x86)\WinSCP\winscp.exe")
                        {
                            Arguments = @"/command ""option batch on"" ""option confirm off"" ""open userx:pwdx@10.1.1.1"" ""put C:\Mobile\Attachments\20.jpeg /tmp/"" ""/log=C:\Users\Administrator\Desktop\test.log"" ""exit""",//working fine
                            //tried this but not working @"/command ""option batch on"" ""option confirm off"" ""open auserx:pwdx@10.1.1.1"" ""put C:\Mobile\Attachments\"+filename +" "+" /tmp/"+ @"/log=C:\Users\Administrator\Desktop\test.log"" ""exit""",
                            //above command created file name log=C:UsersAdministratorDesktoptest.log but not the image name passed.
                            UseShellExecute = false,
                            CreateNoWindow = true
                        };
                        System.Diagnostics.Process.Start(psi);