protected virtual void OnErrorOccurred(ErrorEventArgs e) { this.Status = FTPClientManagerStatus.Idle; if (ErrorOccurred != null) { ErrorOccurred(this, e); } }
/// <summary> /// Initialize a FTPClient instance. /// </summary> public FTPClientManager(Uri url, ICredentials credentials) { this.Credentials = credentials; // Check whether the Url exists and the credentials is correct. // If there is an error, an exception will be thrown. CheckFTPUrlExist(url); this.Url = url; // Set the Status. this.Status = FTPClientManagerStatus.Idle; }
/// <summary> /// 初始化一个FTPClient事例 /// </summary> public FTPClientManager(Uri url, ICredentials credentials) { this.Credentials = credentials; //检查路径是否存在并且认证是否正确 假如有错误,抛出异常 CheckFTPUrlExist(url); this.Url = url; // 设置 Status. this.Status = FTPClientManagerStatus.Idle; }
/// <summary> /// 初始化一个FTPClient实例. /// </summary> public FTPClientManager(Uri url, ICredentials credentials) { this.Credentials = credentials; // 检查URL是否存在和凭据是否正确. // 如果有一个错误,将会抛出异常. CheckFTPUrlExist(url); this.Url = url; // 设置状态 this.Status = FTPClientManagerStatus.Idle; }
/// <summary> /// Download files, directories and their subdirectories. /// </summary> public void DownloadDirectoriesAndFiles(IEnumerable <FTPFileSystem> files, string localPath) { if (this.status != FTPClientManagerStatus.Idle) { throw new ApplicationException("This client is busy now."); } this.Status = FTPClientManagerStatus.Downloading; FTPDownloadClient downloadClient = new FTPDownloadClient(this); downloadClient.FileDownloadCompleted += new EventHandler <FileDownloadCompletedEventArgs>(downloadClient_FileDownloadCompleted); downloadClient.AllFilesDownloadCompleted += new EventHandler(downloadClient_AllFilesDownloadCompleted); downloadClient.DownloadDirectoriesAndFiles(files, localPath); }
/// <summary> /// Upload local folders and files to FTP server. /// </summary> public void UploadFoldersAndFiles(IEnumerable <FileSystemInfo> fileSystemInfos, Uri serverPath) { if (this.status != FTPClientManagerStatus.Idle) { throw new ApplicationException("This client is busy now."); } this.Status = FTPClientManagerStatus.Uploading; FTPUploadClient uploadClient = new FTPUploadClient(this); // Register the events. uploadClient.AllFilesUploadCompleted += new EventHandler(uploadClient_AllFilesUploadCompleted); uploadClient.FileUploadCompleted += new EventHandler <FileUploadCompletedEventArgs>(uploadClient_FileUploadCompleted); uploadClient.UploadDirectoriesAndFiles(fileSystemInfos, serverPath); }
void downloadClient_AllFilesDownloadCompleted(object sender, EventArgs e) { this.Status = FTPClientManagerStatus.Idle; }