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

Author Message
ScottGR

Guest


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 = "";
try
{
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())
{
session.Open(sessionOptions);
WinSCP.TransferOptions transferOptions = new WinSCP.TransferOptions();

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

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

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License