I am pasting my code here for you to look at so that you can tell me if there is anything i am missing.
remoteSession_FileTransferred errros out consistently on a large file. Once it has errored out on a file it seems to keep doing that when i re try too.
The file it gives me trouble is around 198MB and it fails around 187MB. I see a 187MB file that has .filepart extension of remote site.
private void SyncFolders(string srcPath, string dstPath, bool bCreateDestFolder = false)
{
if (Directory.Exists(srcPath))
{
if (bCreateDestFolder)
{
if (!remoteSession.FileExists(dstPath))
{
remoteSession.CreateDirectory(dstPath);
}
}
remoteSession.SynchronizeDirectories(SynchronizationMode.Remote, srcPath, dstPath, true);
}
}
private void ReleaseSoftwareToLfoundary()
{
UpdateStatus("Updating LFoundry FTP Site ..Please wait");
WinSCP.SessionOptions sessionOpts = new SessionOptions();
sessionOpts.HostName = "sftp.lfoundry.com";
sessionOpts.PortNumber = 7788;
sessionOpts.UserName = "username";
sessionOpts.Password = "password";
sessionOpts.Protocol = Protocol.Sftp;
sessionOpts.GiveUpSecurityAndAcceptAnySshHostKey = true;
sessionOpts.TimeoutInMilliseconds = 500000;
bFTPFileTransferError = false;
remoteSession = new Session();
remoteSession.FileTransferred += new FileTransferredEventHandler(remoteSession_FileTransferred);
remoteSession.Open(sessionOpts);
int nCount = 0;
while (remoteSession.Opened == false)
{
Thread.Sleep(200);
nCount++;
if (nCount == 25)//wait for 5 secs
{
itemsFailed++;
AppendToLog("Connecting FTP server Failed");
return;
}
}
try
{
srcPath = PublishFolder + @"ProjectFiles\" + VersionNumber;
dstPath = @"ProjectFiles/" + VersionNumber;
SyncFolders(srcPath, dstPath, true);
}
catch(Exception _ex)
{
};
}
private void remoteSession_FileTransferred(object sender, TransferEventArgs e)
{
if (e.Error != null)
{
bFTPFileTransferError = true;
string message = string.Format("Upload of {0} failed: {1}", e.FileName, e.Error);
AppendToLog(message);
}
else
{
string message = string.Format("Trasfered file {0} To FTP Site", e.FileName);
AppendToLog(message);
}
}