示例#1
0
        public void FileIsCorrupt()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();

            extractor.SaveToFolder("TestFiles\\A corrupt compound document.doc", outputFolder);
        }
示例#2
0
        public void OdpWithPassword()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();

            extractor.SaveToFolder("TestFiles\\An ODP document with password.odp", outputFolder);
        }
示例#3
0
        public void DocWithPassword()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();

            extractor.SaveToFolder("TestFiles\\A DOC word document with password.doc", outputFolder);
        }
示例#4
0
 public void DocxWithoutEmbeddedFiles()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     var files = extractor.SaveToFolder("TestFiles\\A DOCX word document without embedded files.docx", outputFolder);
     Assert.IsTrue(files.Count == 0);
 }
        public void DocWithDocumentOleObjectAttachedPathBroken()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();

            extractor.SaveToFolder("TestFiles\\A DOC word document with document ole object attached path broken.doc", outputFolder);
        }
示例#6
0
        public void PptxWithPassword()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();

            extractor.SaveToFolder("TestFiles\\A PPTX PowerPoint document with password.pptx", outputFolder);
        }
示例#7
0
        public void XlsxWithPassword()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();

            extractor.SaveToFolder("TestFiles\\A XLSX excel document with password.xlsx", outputFolder);
        }
示例#8
0
        public void FileTypeNotSupported()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();

            extractor.SaveToFolder("TestFiles\\filetypenotsupported.txt", outputFolder);
        }
        public void RtfWitht3EmbeddedFilesAndNoSpaceDelimiters()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\A RTF document with 3 embedded files and no space delimiters.rtf", outputFolder);

            Assert.IsTrue(files.Count == 3);
        }
示例#10
0
        public void DocWith2EmbeddedImages()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\A DOC word document with embedded images.doc", outputFolder);

            Assert.IsTrue(files.Count == 2);
        }
示例#11
0
        public void DocWithoutEmbeddedFiles()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.Extract("TestFiles\\A DOC word document without embedded files.doc", outputFolder);

            Assert.IsTrue(files.Count == 0);
        }
示例#12
0
        public void OdsWith2EmbeddedFiles()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.Extract("TestFiles\\An ODS document with 2 embedded files.ods", outputFolder);

            Assert.IsTrue(files.Count == 2);
        }
示例#13
0
        public void PptWithoutEmbeddedFiles()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.Extract("TestFiles\\A PPT PowerPoint document without embedded files.ppt", outputFolder);

            Assert.IsTrue(files.Count == 0);
        }
示例#14
0
        public void XlsxWith2EmbeddedFiles()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\A XLSX excel document with 2 embedded files.xlsx", outputFolder);

            Assert.IsTrue(files.Count == 2);
        }
示例#15
0
        public void RtfWitht11EmbeddedFiles()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\A RTF document with 11 embedded files.rtf", outputFolder);

            Assert.IsTrue(files.Count == 11);
        }
示例#16
0
        public void DocxWithEmbeddedMathTypeObjectSuccessfulExtractsNothing()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\MathType 5 Object.docx", outputFolder);

            Assert.AreEqual(0, files.Count);
        }
示例#17
0
        public void PptxWith3EmbeddedFiles()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\A PPTX powerpoint document with 3 embedded files.pptx", outputFolder);

            Assert.IsTrue(files.Count == 3);
        }
示例#18
0
        public void OdpWith3EmbeddedFiles()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\An ODP document with 3 embedded files.odp", outputFolder);

            Assert.IsTrue(files.Count == 3);
        }
示例#19
0
        public void PptWithEmbeddedMsClipArtGalleryObject()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\A PPT PowerPoint document containing a MS ClipArt Gallery object.ppt", outputFolder);

            Assert.IsTrue(files.Count == 0);
        }
示例#20
0
        public void DocxWith7EmbeddedFiles()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\A DOCX word document with 7 embedded files.docx", outputFolder);

            Assert.IsTrue(files.Count == 7);
        }
示例#21
0
        public void DocWithDocumentOleObjectAttachedPathRemoved()
        {
            var outputFolder = CreateTemporaryFolder();
            var extractor    = new OfficeExtractor.Extractor();
            var files        = extractor.SaveToFolder("TestFiles\\A DOC word document with document ole object attached path removed.doc", outputFolder);

            Assert.IsTrue(files.Count == 1);
            Assert.AreEqual(Path.GetFileName(files[0]), "Embedded object.pdf");
        }
        private void SelectButton_Click(object sender, EventArgs e)
        {
            // Create an instance of the opeKn file dialog box.
            var openFileDialog1 = new OpenFileDialog
            {
                // ReSharper disable once LocalizableElement
                Filter = "Microsoft Office files|*.ODT;*.DOC;*.DOCM;*.DOCX;*.DOT;*.DOTM;*.DOTX;*.RTF;*.XLS;*.XLSB;*.XLSM;*.XLSX;*.XLT;" +
                         "*.XLTM;*.XLTX;*.XLW;*.POT;*.PPT;*.POTM;*.POTX;*.PPS;*.PPSM;*.PPSX;*.PPTM;*.PPTX",
                FilterIndex = 1,
                Multiselect = false
            };

            // Process input if the user clicked OK.
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                // Open the selected file to read.
                string tempFolder = null;

                try
                {
                    tempFolder = GetTemporaryFolder();
                    _tempFolders.Add(tempFolder);

                    var extractor = new OfficeExtractor.Extractor();
                    var files     = extractor.Extract(openFileDialog1.FileName, tempFolder);
                    FilesListBox.Items.Clear();

                    if (files == null)
                    {
                        return;
                    }
                    foreach (var file in files)
                    {
                        FilesListBox.Items.Add(file);
                    }
                }
                catch (Exception ex)
                {
                    if (tempFolder != null && Directory.Exists(tempFolder))
                    {
                        Directory.Delete(tempFolder, true);
                    }

                    MessageBox.Show(GetInnerException(ex));
                }
            }
        }
示例#23
0
        private void oleBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            for (int i = 0; i < openFileDialog1.FileNames.Length; i++)
            {
                try
                {
                    string file = openFileDialog1.FileNames[i];
                    string outputFileDirectory = Path.Combine(folderBrowserDialog1.SelectedPath,
                                                              Path.GetFileNameWithoutExtension(file));
                    if (!Directory.Exists(outputFileDirectory))
                    {
                        Directory.CreateDirectory(outputFileDirectory);
                    }

                    var extractor = new OfficeExtractor.Extractor();
                    var oleFiles  = extractor.Extract(file, outputFileDirectory);
                    filesListBox.Items.Add(Path.GetFileName(file));
                    for (int j = 1; j <= oleFiles.Count; j++)
                    {
                        if (j != oleFiles.Count)
                        {
                            oleBackgroundWorker.ReportProgress(
                                (int)((i + ((decimal)j / oleFiles.Count)) / openFileDialog1.FileNames.Length * 100),
                                "├───" + Path.GetFileName(oleFiles[j - 1]));
                        }
                        else
                        {
                            oleBackgroundWorker.ReportProgress(
                                (int)((i + ((decimal)j / oleFiles.Count)) / openFileDialog1.FileNames.Length * 100),
                                "└───" + Path.GetFileName(oleFiles[j - 1]));
                        }
                    }
                    _recentOutputPath = folderBrowserDialog1.SelectedPath;
                    if (!Directory.EnumerateFileSystemEntries(outputFileDirectory).Any())
                    {
                        Directory.Delete(outputFileDirectory);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#24
0
        private void SelectButton_Click(object sender, EventArgs e)
        {
            // Create an instance of the opeKn file dialog box.
            var openFileDialog1 = new OpenFileDialog
            {
                // ReSharper disable once LocalizableElement
                Filter = "Microsoft Office files|*.ODT;*.DOC;*.DOCM;*.DOCX;*.DOT;*.DOTM;*.RTF;*.XLS;*.XLSB;*.XLSM;*.XLSX;*.XLT;" +
                                                     "*.XLTM;*.XLTX;*.XLW;*.POT;*.PPT;*.POTM;*.POTX;*.PPS;*.PPSM;*.PPSX;*.PPTM;*.PPTX",
                FilterIndex = 1,
                Multiselect = false
            };

            // Process input if the user clicked OK.
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                // Open the selected file to read.
                string tempFolder = null;

                try
                {
                    tempFolder = GetTemporaryFolder();
                    _tempFolders.Add(tempFolder);

                    var extractor = new OfficeExtractor.Extractor();
                    var files = extractor.SaveToFolder(openFileDialog1.FileName, tempFolder);
                    FilesListBox.Items.Clear();

                    if (files == null) return;
                    foreach (var file in files)
                        FilesListBox.Items.Add(file);
                }
                catch (Exception ex)
                {
                    if (tempFolder != null && Directory.Exists(tempFolder))
                        Directory.Delete(tempFolder, true);

                    MessageBox.Show(GetInnerException(ex));
                }
            }
        }
示例#25
0
 public void XlsxWithPassword()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     extractor.SaveToFolder("TestFiles\\A XLSX excel document with password.xlsx", outputFolder);
 }
示例#26
0
 public void PptxWith3EmbeddedFiles()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     var files = extractor.SaveToFolder("TestFiles\\A PPTX powerpoint document with 3 embedded files.pptx", outputFolder);
     Assert.IsTrue(files.Count == 3);
 }
示例#27
0
 public void PptxWithPassword()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     extractor.SaveToFolder("TestFiles\\A PPTX PowerPoint document with password.pptx", outputFolder);
 }
示例#28
0
 public void OdpWith3EmbeddedFiles()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     var files = extractor.SaveToFolder("TestFiles\\An ODP document with 3 embedded files.odp", outputFolder);
     Assert.IsTrue(files.Count == 3);
 }
示例#29
0
 public void OdpWithPassword()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     extractor.SaveToFolder("TestFiles\\An ODP document with password.odp", outputFolder);
 }
示例#30
0
 public void FileTypeNotSupported()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     extractor.SaveToFolder("TestFiles\\filetypenotsupported.txt", outputFolder);
 }
示例#31
0
 public void FileIsCorrupt()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     extractor.SaveToFolder("TestFiles\\A corrupt compound document.doc", outputFolder);
 }
示例#32
0
 public void DocxWithPassword()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     extractor.SaveToFolder("TestFiles\\A DOCX word document with password.docx", outputFolder);
 }
示例#33
0
 public void XlsxWith2EmbeddedFiles()
 {
     var outputFolder = CreateTemporaryFolder();
     var extractor = new OfficeExtractor.Extractor();
     var files = extractor.SaveToFolder("TestFiles\\A XLSX excel document with 2 embedded files.xlsx", outputFolder);
     Assert.IsTrue(files.Count == 2);
 }