Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: Issue with the code

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Though, you should use WinSCP .NET assembly instead:

Issue with the code


I am trying to put the zip file from my system to sftp server using the following code.
Most of the information like sftpusername , sftppassword etc are self-explanatory. In case any information is required feel free to ask
But it is failing more often then not I am using WinSCP version 5.9.2 (build 6958). I am using the code below in C#.
The issue occurs when the WinSCP is not able to connect in 15 seconds. After that when it tries to it takes dir, ls as inputs for username and password rather than sftpusername and sftppassword.
//Console.WriteLine("Password: ----->" + sftppassword);
// winscp.StandardInput.WriteLine("-hostkey=" +hostkey);
// Creating directories if not already present
winscp.StandardInput.WriteLine("mkdir " + path);
// Traversing to the required directory
winscp.StandardInput.WriteLine("cd " + path);
//Putting the zip file onto the server
winscp.StandardInput.WriteLine("put " + zippath);
string output = winscp.StandardOutput.ReadToEnd();
// completly shutting down the process

The attach log has the issue captured.

Is there a possibility to make it more robust and user-friendly.
Let me know in case any further details or information is required.

Thanks in Advance