예제 #1
0
        /// <summary>
        /// Deletes an Ftp directory on the ftp server.
        /// </summary>
        private void DeleteDirectory()
        {
            if (string.IsNullOrEmpty(this.RemoteDirectoryName))
            {
                this.Log.LogError("The required RemoteDirectoryName attribute has not been set for FTP.");
                return;
            }

            using (FtpConnection ftpConnection = this.CreateFtpConnection())
            {
                ftpConnection.LogOn();
                this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Deleting Directory: {0}", this.RemoteDirectoryName));
                try
                {
                    ftpConnection.DeleteDirectory(this.RemoteDirectoryName);
                }
                catch (FtpException ex)
                {
                    if (ex.Message.Contains("550"))
                    {
                        return;
                    }

                    this.Log.LogError(string.Format(CultureInfo.CurrentCulture, "There was an error deleting ftp directory: {0}. The Error Details are \"{1}\" and error code is {2} ", this.RemoteDirectoryName, ex.Message, ex.ErrorCode));
                }
            }
        }