Topic "Contents .NET Assembly Session Class session.PutFiles"

Author Message


Using the .net assembly, we are trying to put a 2MB file to an sftp server. The "filepart" is copied and deleted. Changed to an ASCII transfer and the zip file was put on the server, but two bytes were incorrect. Could not find a programmatic way to disable the auto reconnect. Is anyone using this successfully? Is there a limitation with the sftp server? Here is the code:

public static string WinSCPIt(string host, int port, string username, string password, string remoteDir, string zipFile, string destFile)
string strMessage = "";
SessionOptions sessionOptions = new SessionOptions
Protocol = Protocol.Sftp,
HostName = host,
UserName = username,
Password = password,
PortNumber = port,
SshHostKeyFingerprint = "some valid key" // removed for post

using (WinSCP.Session session = new WinSCP.Session())
WinSCP.TransferOptions transferOptions = new WinSCP.TransferOptions();

TransferOperationResult transferResult;
transferResult = session.PutFiles(zipFile, remoteDir + "/", false, transferOptions);

// Throw on any error
return strMessage;
catch (Exception ex)
strMessage = "WinSCP Error occured: " + ex.Message;
return strMessage;
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24759
Location: Prague, Czechia
Sorry, I do not understand the problem. Can you try again? Or post a log file.
Martin Prikryl

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License