首页 > 解决方案 > .net使用winscp将文件从windows移动到linux

问题描述

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

  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);

标签: c#.net

解决方案



推荐阅读