I am having a very similar problem. I have implemented a multithreaded C# application that does the upload in a separate thread and then fires events to the main thread to update a progress bar, status bar, etc. It works perfectly for all smaller files I have tried (50k, 1 MB, 2MB, etc). I get this in my status window:
[06/13/2006 04:13:59] Setting up File Transfer.
[06/13/2006 04:13:59] Transferring file ... [from the Uploading event]
[06/13/2006 04:15:25] Transfer Complete. [from the Uploaded event]
When I upload a 432 MB ASCII semicolon-delimited file, the status is updated regularly until it gets to the final stage - the progress bar reads 100%, it says it has transferred 442968.75 KB out of 442968.75 KB, but the Uploaded event never fires and my "ThreadComplete" event (which fires when the threaded method ends) never fires either. This also happened with a 180.37 MB ZIP file. I left the application running for several minutes after it got to the final byte to see if it would ever complete, but it never did.
I checked the remote file and it is the exact same size as my local file. I also got the MD5 hash of each file, and they are identical - so the FTP was completed, but the FTP component never completed and exited. There is still plenty of disk space (10+ GB) left on the server. I tried using Binary instead of ASCII transfer type, and it did the same thing.
The code that creates the thread is:
FTPThread ftpThread = new FTPThread();
ftpThread.BytesTransferred+=new BytesTransferredHandler(ftpThread_BytesTransferred);
ftpThread.Uploaded += new FTPFileTransferEventHandler(ftpThread_Uploaded);
ftpThread.ThreadComplete += new EventHandler(ftpThread_ThreadComplete);
ftpThread.ExceptionOccurred += new FTPThread.ExceptionEventHandler(ftpThread_ExceptionOccurred);
ftpThread.Uploading += new FTPFileTransferEventHandler(ftpThread_Uploading);
threadFTP = new System.Threading.Thread(ftpThread.BeginUpload);
threadFTP.Start();
The code for my threaded method is:
public void BeginUpload()
{
try
{
// Set server and log-in properties
ftpConn.ServerAddress = _host.ToString();
ftpConn.ServerPort = _serverPort;
ftpConn.UserName = _userName.ToString();
ftpConn.Password = _password.ToString();
// Connect, put, and close
ftpConn.Connect();
ftpConn.UploadFile(_fileToUpload, _remoteFileName, false);
}
catch (Exception ex)
{
ExceptionOccurred(this, ex);
}
finally
{
if (ftpConn != null && ftpConn.IsConnected)
ftpConn.Close();
}
ThreadComplete(this, new EventArgs());
}