Esempio n. 1
0
        private void _extractAllArchiveItemsButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Directory.Exists(_archiveOutputFolderTextBox.Text))
                {
                    MessageBox.Show("Archive Output folder does not exist: " + _archiveOutputFolderTextBox.Text);
                    return;
                }

                _hostUI.ShowBusy(true);

                var archiveExtractHelper = new ArchiveExtractorHelper(_archiveContent, _archiveExtractor, _hostUI);

                archiveExtractHelper.ExtractItemsToDirectory(_archiveOutputFolderTextBox.Text);

                MessageBox.Show(this, string.Format("Extracted and wrote {0} archive items in {1:F3} [secs]",
                                                    archiveExtractHelper.TotalItemsExtracted, archiveExtractHelper.TotalElapsedTimeMs / 1000.0), "Finished");
            }
            catch (Exception ex)
            {
                _hostUI.LogMessage("Error extracting archive items: " + ex.Message);
                _hostUI.ShowMessageBox(ex.Message, "Error extracting archive items...");
            }
            finally
            {
                _hostUI.ShowBusy(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Test archive items for actual expansion size and extraction errors BEFORE
        /// extracting - as a measure of security.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _testArchiveButton_Click(object sender, EventArgs e)
        {
            try
            {
                _hostUI.ShowBusy(true);

                var archiveExtractHelper = new ArchiveExtractorHelper(_archiveContent, _archiveExtractor, _hostUI);

                archiveExtractHelper.TestItems();
                UpdateArchiveItemListView();

                // If test is successful we add calculated metadata fields TestedExpandedSizeInBytes and TestedCompressionRatio,
                // so update Metadata list view:
                if (_archiveContent.Metadata.Count > 0)
                {
                    MetadataHelper.PopulateListViewWithMetadata(_metadataListView, _archiveContent.Metadata);
                }

                _metdataTabPage.Text = string.Format("Metadata ({0})", _archiveContent.Metadata.Count);
            }
            catch (Exception ex)
            {
                _hostUI.LogMessage("Error testing archive items: " + ex.Message);
                _hostUI.ShowMessageBox(ex.Message, "Error testing archive items...");
            }
            finally
            {
                UpdateArchiveItemListView();
                _hostUI.ShowBusy(false);
            }
        }