A little background on this error: The customer getting this error message in their log file and support hasn't been able to reproduce it yet. So I'm reviewing the code trying to determine what may be happening. I have narrowed it down to this section of the code by reviewing their log file. I didn't write this code, but it's purpose is to ftp a zip file to a remote server. So the question is....
What line(s) this code might throw a "Index was outside the bounds of the array" exception?
FtpLib.FTPFactory ff = new FtpLib.FTPFactory();
try
{
ff.setRemoteHost(job.FTPHost);
ff.setRemoteUser(job.FTPUser);
ff.setRemotePass(job.FTPPW);
ff.login();
// Execute misc. extra commands
foreach (string command in job.Commands)
{
if (log.IsDebugEnabled)
log.Debug("JOB: " + job.ID + " -- FTP Command \"" + command + "\" sent...");
ff.sendCommand(command);
if (log.IsDebugEnabled)
log.Debug("JOB: " + job.ID + " -- Response: " + ff.getLastMessage());
}
try
{
ff.mkdir(job.FTPRemoteDir);
}
catch (IOException) { }
ff.chdir(job.FTPRemoteDir);
ff.setBinaryMode(true);
if (log.IsInfoEnabled)
log.Info("JOB: " + job.ID + " -- FTP UPLOAD: \"" + zipfile.Name + "\" to \"" + job.FTPHost + "/" + job.FTPRemoteDir + "/\"");
ff.upload(zipfile.FullName);
if (log.IsInfoEnabled)
log.Info("JOB: " + job.ID + " -- Completed.");
bFTPSuccess = true;
break;
}
Thanks in advance!
UPDATE: I think we all pretty much agree that the issue is going to be in the FTPLib, I'll see if we have the source for it. I found out this is an obscure bug the customer can't even reproduce consistently, so this will be a fun one pin point. I have added additional debug logging using Exception.StackTrace and Exception.ToString functions. I'll update again once the issue is solved and try to award the correct person with the correct answer, although everyone has made good suggestions. Thanks for the help!