Afzal
Afzal

Reputation: 31

.net moving file from windows to linux using winscp

Writing code to move file from windows client to remote linux server. The code executes fine by keeping static file name, but while passing filename dynamically, code doesnt works as expected.Below is the code, pls suggest. Thanks, Afzal.

  var psi = new System.Diagnostics.ProcessStartInfo(@"c:\Program Files (x86)\WinSCP\winscp.exe")
                        {
                            Arguments = @"/command ""option batch on"" ""option confirm off"" ""open userx:[email protected]"" ""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:[email protected]"" ""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);

Upvotes: 1

Views: 539

Answers (1)

Afzal
Afzal

Reputation: 31

resolved issue by using winscp library and code from below url.

https://winscp.net/eng/docs/library_install https://winscp.net/eng/docs/library#downloading_and_installing_the_assembly

Upvotes: 1

Related Questions