public static void UploadFileTest(MainForm frm) { PFWinFTP ftp = new PFWinFTP(); Stopwatch sw = new Stopwatch(); try { sw.Start(); _msg.Length = 0; _msg.Append("UploadFileTest started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); InitializeFtpFromForm(frm, ftp); //_msg.Length = 0; //_msg.Append("_ftp object:\r\n"); //_msg.Append(_ftp.ToString()); //Program._messageLog.WriteLine(_msg.ToString()); ftp.UploadFileToFtpHost(); if (ftp.RemoteFileExists(frm.txtRemoteFile.Text)) { _msg.Length = 0; _msg.Append(frm.txtRemoteFile.Text); _msg.Append(" was written to "); _msg.Append(ftp.FtpHost); } else { _msg.Length = 0; _msg.Append("Unable to find "); _msg.Append(frm.txtRemoteFile.Text); _msg.Append(" on "); _msg.Append(ftp.FtpHost); } Program._messageLog.WriteLine(_msg.ToString()); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { sw.Stop(); _msg.Length = 0; _msg.Append("\r\nElapsed time: "); _msg.Append(sw.FormattedElapsedTime); Program._messageLog.WriteLine(_msg.ToString()); _msg.Length = 0; _msg.Append("\r\n... UploadFileTest finished."); Program._messageLog.WriteLine(_msg.ToString()); } }
public static void DeleteRemoteFileTest(MainForm frm) { PFWinFTP ftp = new PFWinFTP(); Stopwatch sw = new Stopwatch(); try { sw.Start(); _msg.Length = 0; _msg.Append("DeleteRemoteFileTest started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); InitializeFtpFromForm(frm, ftp); if (ftp.RemoteFileExists(frm.txtRemoteFile.Text)) { _msg.Length = 0; _msg.Append(frm.txtRemoteFile.Text); _msg.Append(" exists on "); _msg.Append(ftp.FtpHost); Program._messageLog.WriteLine(_msg.ToString()); } else { _msg.Length = 0; _msg.Append("Unable to find "); _msg.Append(frm.txtRemoteFile.Text); _msg.Append(" on "); _msg.Append(ftp.FtpHost); throw new FileNotFoundException(_msg.ToString()); } bool deleteSucceeded = ftp.DeleteRemoteFile(frm.txtRemoteFile.Text); if (deleteSucceeded) { Program._messageLog.WriteLine("Delete succeeded."); } else { Program._messageLog.WriteLine("Delete failed."); } if (ftp.RemoteFileExists(frm.txtRemoteFile.Text)) { _msg.Length = 0; _msg.Append(frm.txtRemoteFile.Text); _msg.Append(" exists on "); _msg.Append(ftp.FtpHost); Program._messageLog.WriteLine(_msg.ToString()); } else { _msg.Length = 0; _msg.Append("Unable to find "); _msg.Append(frm.txtRemoteFile.Text); _msg.Append(" on "); _msg.Append(ftp.FtpHost); Program._messageLog.WriteLine(_msg.ToString()); } } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { sw.Stop(); _msg.Length = 0; _msg.Append("\r\nElapsed time: "); _msg.Append(sw.FormattedElapsedTime); Program._messageLog.WriteLine(_msg.ToString()); _msg.Length = 0; _msg.Append("\r\n... DeleteRemoteFileTest finished."); Program._messageLog.WriteLine(_msg.ToString()); } }