Ejemplo n.º 1
0
        private void DoExtract()
        {
            var processor = new Processor
            {
                OnStartProcessFile = (filename) => { Console.WriteLine(filename); }
            };

            if (checkBoxSortXml.Checked)
            {
                processor.AddFilter(new Sortify());
            }

            if (checkBoxIndentXml.Checked)
            {
                processor.Indented = true;
            }

            if (checkBoxStrictOpenXml.Checked)
            {
                processor.AddFilter(new Strictify());
            }

            if (checkBoxTraverseSubdirectories.Checked)
            {
                processor.SubFolders = true;
            }

            try
            {
                using (var zip = ZipFile.Read(textBoxSource.Text))
                {
                    zip.ExtractAll(textBoxDestination.Text, ExtractExistingFileAction.OverwriteSilently);
                }

                processor.ProcessFolder(textBoxDestination.Text, "*.xml");
                MessageBox.Show($"Extracted to '{textBoxDestination.Text}'", Resources.Form1_DoExtract_XmlTools_UI, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (IOException ioex)
            {
                MessageBox.Show(ioex.Message, Resources.Form1_DoExtract_XmlTools_UI, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }