/// <summary> /// The asynchronous ftp operation to perform. /// </summary> /// <param name="socketDirection">Socket operation to perform.</param> /// <returns>True if the ftp operation succeed else false.</returns> private bool AsynchronousFtpOperation(Nequeo.Net.Ftp.SocketTransferDirection socketDirection) { // Set the initial return to false. bool ret = false; // Validate the properties before any // Ftp operation. ValidateProperties(socketDirection); switch (socketDirection) { case Nequeo.Net.Ftp.SocketTransferDirection.Upload: // Start uploading the local target file to the // ftp server source path file. ret = ftpAsycClient.Upload(this.ftpAdapter, this.uploadTarget, new Uri("ftp://" + this.FTPAdapter.FTPServer + (this.FTPAdapter.Port != 21 ? ":" + this.FTPAdapter.Port.ToString() : "") + "/" + this.ftpUploadSourcePath)); break; case Nequeo.Net.Ftp.SocketTransferDirection.Download: // Start downloading the ftp server source path file // to the local destination path. ret = ftpAsycClient.Download(this.ftpAdapter, this.downloadDestination, new Uri("ftp://" + this.FTPAdapter.FTPServer + (this.FTPAdapter.Port != 21 ? ":" + this.FTPAdapter.Port.ToString() : "") + "/" + this.ftpDownloadSourcePath)); break; } // Return true if the process // completed successfully. return(ret); }
/// <summary> /// The ftp operation to perform. /// </summary> /// <param name="socketDirection">Socket operation to perform.</param> /// <returns>True if the ftp operation succeed else false.</returns> private bool FtpOperation(Nequeo.Net.Ftp.SocketTransferDirection socketDirection) { // Set the initial return to false. bool ret = false; // Validate the properties before any // Ftp operation. ValidateProperties(socketDirection); switch (socketDirection) { case Nequeo.Net.Ftp.SocketTransferDirection.Upload: // Start uploading the local target file to the // ftp server source path file. ret = ftpClient.Upload(this.ftpAdapter, this.uploadTarget, new Uri("ftp://" + this.FTPAdapter.FTPServer + (this.FTPAdapter.Port != 21 ? ":" + this.FTPAdapter.Port.ToString() : "") + "/" + this.ftpUploadSourcePath)); break; case Nequeo.Net.Ftp.SocketTransferDirection.Download: // Start downloading the ftp server source path file // to the local destination path. ret = ftpClient.Download(this.ftpAdapter, this.downloadDestination, new Uri("ftp://" + this.FTPAdapter.FTPServer + (this.FTPAdapter.Port != 21 ? ":" + this.FTPAdapter.Port.ToString() : "") + "/" + this.ftpDownloadSourcePath)); break; case Nequeo.Net.Ftp.SocketTransferDirection.DeleteFile: // Start delete file the ftp server source path file // to the local destination path. ret = ftpClient.DeleteFile(this.ftpAdapter, new Uri("ftp://" + this.FTPAdapter.FTPServer + (this.FTPAdapter.Port != 21 ? ":" + this.FTPAdapter.Port.ToString() : "") + "/" + this.FtpDeleteFileSourcePath)); break; case Nequeo.Net.Ftp.SocketTransferDirection.DirectoryList: // List of all the files in the directory. List <string> fileList = null; // Start downloading the directory list from the // ftp server source path. ret = ftpClient.DirectoryList(this.ftpAdapter, new Uri("ftp://" + this.FTPAdapter.FTPServer + (this.FTPAdapter.Port != 21 ? ":" + this.FTPAdapter.Port.ToString() : "") + "/" + this.ftpDirectoryListPath), out fileList); // Assign the file list to the // property value, returns the // list of files. directoryList = fileList; break; } // Return true if the process // completed successfully. return(ret); }
/// <summary> /// Constructor for the ftp process event argument. /// </summary> /// <param name="ftpServer">The ftp server connecting to.</param> /// <param name="ftpProcess">The original command that was to be processed.</param> /// <param name="fileInfo">The original upload target file, download destination file or /// the list of files within a directory.</param> /// <param name="ftpStatusCode">The current ftp status code from the server.</param> /// <param name="ftpStatusDescription">The current ftp status description from the server.</param> /// <param name="transferDirection">The current ftp transfer direction.</param> public FTPSocketArgs(string ftpServer, string ftpProcess, string fileInfo, FtpStatusCode ftpStatusCode, string ftpStatusDescription, Nequeo.Net.Ftp.SocketTransferDirection transferDirection) { this.fileInfo = fileInfo; this.ftpServer = ftpServer; this.ftpProcess = ftpProcess; this.ftpStatusCode = ftpStatusCode; this.transferDirection = transferDirection; this.ftpStatusDescription = ftpStatusDescription; }
/// <summary> /// The Ftp validation operation to perform. /// </summary> /// <param name="socketDirection">Socket operation to perform.</param> private void ValidateProperties(Nequeo.Net.Ftp.SocketTransferDirection socketDirection) { // Make sure that the ftp adapter exists. if (this.ftpAdapter == null) { throw new FTPClientConnectionException( new NullReferenceException("The Ftp Connection " + "Adapter has not been set.")); } switch (socketDirection) { case Nequeo.Net.Ftp.SocketTransferDirection.Upload: // Make sure that an upload target exists. if (this.uploadTarget == string.Empty) { throw new FTPClientConnectionException("The local upload " + "target path has not been set."); } // Make sure that an upload source exists. if (this.ftpUploadSourcePath == string.Empty) { throw new FTPClientConnectionException("The ftp server upload " + "path has not been set."); } break; case Nequeo.Net.Ftp.SocketTransferDirection.Download: // Make sure that a download destination exists. if (this.downloadDestination == string.Empty) { throw new FTPClientConnectionException("The local download " + "destination path has not been set."); } // Make sure that a download source exists. if (this.ftpDownloadSourcePath == string.Empty) { throw new FTPClientConnectionException("The ftp server download " + "path has not been set."); } break; case Nequeo.Net.Ftp.SocketTransferDirection.DeleteFile: // Make sure that the delete file exists. if (this.ftpDeleteFileSourcePath == string.Empty) { throw new FTPClientConnectionException("The ftp server delete file " + "path has not been set."); } break; case Nequeo.Net.Ftp.SocketTransferDirection.DirectoryList: // Make sure that a download directory list exists. if (this.ftpDirectoryListPath == string.Empty) { throw new FTPClientConnectionException("The ftp server directory list " + "path has not been set."); } break; } }