public void FileIsCorrupt() { var outputFolder = CreateTemporaryFolder(); var extractor = new OfficeExtractor.Extractor(); extractor.SaveToFolder("TestFiles\\A corrupt compound document.doc", outputFolder); }
public void OdpWithPassword() { var outputFolder = CreateTemporaryFolder(); var extractor = new OfficeExtractor.Extractor(); extractor.SaveToFolder("TestFiles\\An ODP document with password.odp", outputFolder); }
public void DocWithPassword() { var outputFolder = CreateTemporaryFolder(); var extractor = new OfficeExtractor.Extractor(); extractor.SaveToFolder("TestFiles\\A DOC word document with password.doc", outputFolder); }
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); }
public void PptxWithPassword() { var outputFolder = CreateTemporaryFolder(); var extractor = new OfficeExtractor.Extractor(); extractor.SaveToFolder("TestFiles\\A PPTX PowerPoint document with password.pptx", outputFolder); }
public void XlsxWithPassword() { var outputFolder = CreateTemporaryFolder(); var extractor = new OfficeExtractor.Extractor(); extractor.SaveToFolder("TestFiles\\A XLSX excel document with password.xlsx", outputFolder); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); } } }
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); } } }
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)); } } }
public void DocxWithPassword() { var outputFolder = CreateTemporaryFolder(); var extractor = new OfficeExtractor.Extractor(); extractor.SaveToFolder("TestFiles\\A DOCX word document with password.docx", outputFolder); }