Пример #1
0
        private void btnCleanup_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("Are you sure to want to delete ALL POSTS and UPLOADS, including IMAGES from the blog?",
                         "Confirm Delete!!",
                         MessageBoxButtons.YesNo);
            if (confirmResult != DialogResult.Yes) return;

            var programOptionsFactory = new ProgramOptionsFactory();
            _options = programOptionsFactory.Get();
            if (string.IsNullOrEmpty(_options.FtpUrl))
            {
                MessageBox.Show("In order to delete images, please set up FTP account from settings.");
                return;
            }
            _ftp = new Ftp.Ftp(FtpConfiguration);
            if (!string.IsNullOrEmpty(_ftp.TestConnection()))
            {
                MessageBox.Show("Cannot connect to FTP, please check your settings.");
                return;
            }
            try
            {
                _ftp.DirectoryListingProgressing += FtpDirectoryListingProgressing;
                _ftp.DirectoryListingFetchFinished += FtpDirectoryListingFetchFinished;
                _ftp.DirectoryDeletionProgressing += FtpDirectoryDeletionProgress;
                _ftp.DirectoryDeletionFinished += FtpDirectoryDeletionFinished;
                EnDis(false);
                _ftp.DeleteDirectory("wp-content/uploads/");

            }
            catch (Exception exception)
            {
                EnDis(true);

                MessageBox.Show(exception.ToString());
                Logger.LogExceptions(exception);
            }
        }