I am using 1.2.5 edtftpnet.dll, with dot net framework 2.0. Randomly I get error "Exception has been thrown by the target of an invocation" while uploading the file. I have loop which keep on uploading the files from particular directory. It work file for most of the time but once a while it give this error and then it never uploads that file in the loop. I have to stop the program and then restart it. Then it will work fine. Please tell me how to overcome this problem. My code is as follows:
FTPcon = new EnterpriseDT.Net.Ftp.FTPConnection();
private void connectionToFTP()
{
FTPcon.ServerAddress = "255.255.255.0";
FTPcon.UserName = "administrator";
FTPcon.Password = "*****";
FTPcon.Connect();
}
private void FTPUploadAutomatically()
{
for (int i = 0; i < lstFiles.Items.Count; i++)
{
if (!FTPcon.IsConnected)
{
connectionToFTP();
}
try
{
FTPcon.UploadFile( lstFiles.Items[i].Text , FTPPath + lstFiles.Items[i].Text );
}
}