private void chooseFileButton_Click(object sender, EventArgs e) { int numberOfSelectedFiles = 0; if (destinationFolderTextBox.Text == "") { showMessageBox(); } else { OpenFileDialog openFileDialog1 = new OpenFileDialog { Filter = "PDF|*.PDF", Multiselect = true }; if (openFileDialog1.ShowDialog() == DialogResult.OK) { destinationFolderTextBox.Enabled = false; foreach (string item in openFileDialog1.FileNames) { pdfFile file = new pdfFile(item); pdfFiles.Add(file); numberOfSelectedFiles++; createItem(file); } } selectedFiles(numberOfSelectedFiles); } }
private void createItem(pdfFile file) { PDFViewItem viewItem = new PDFViewItem(); viewItem.Width = panel.Width - 29; viewItem.drawItems(panel.Width); viewItems.Add(viewItem); viewItem.Width = panel.Width - 33; panel.Controls.Add(viewItem); }
public void setListFile() { listFileOfSourceProject.Clear(); if (this != null) { try { string path = this.pathSourceFolder; foreach (string item in Directory.GetFiles(path)) { FileInfo fi = new FileInfo(item); string extension = fi.Extension; if (listfileextension.Contains(extension)) { if (extension == ".txt") { file a = new txtFile(); a.setFileName(fi.FullName); //a.readContent(a.filePath); string pathFile = Path.Combine(pathSaveFolder, a.getFileNameSave()); a.loadFileSave(pathFile); listFileOfSourceProject.Add(a); } if (extension == ".docx" || extension == ".doc") { file a = new wordFile(); a.setFileName(fi.FullName); string pathFile = Path.Combine(pathSaveFolder, a.getFileNameSave()); a.loadFileSave(pathFile); listFileOfSourceProject.Add(a); } if (extension == ".pdf") { file a = new pdfFile(); a.setFileName(fi.FullName); string pathFileSave = Path.Combine(pathSaveFolder, a.getFileNameSave()); a.loadFileSave(pathFileSave); //a.copy(); string pathFile = Path.Combine(pathSourceFolder, fi.FullName); //a.convertToWord(pathFile,pathTempFolder); listFileOfSourceProject.Add(a); } } } } catch (Exception) { } } }
private void chooseFileButton_DragDrop_1(object sender, DragEventArgs e) { int numberOfSelectedFiles = 0; if (destinationFolderTextBox.Text == "") { showMessageBox(); } else { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false); bool found = false; foreach (string item in files) { if (System.IO.Path.GetExtension(item) != ".pdf") { showDragAndDropMessageBox(); found = true; break; } } if (!found) { foreach (string item in files) { if (System.IO.Path.GetExtension(item) != ".pdf") { showDragAndDropMessageBox(); } else { pdfFile file = new pdfFile(item); pdfFiles.Add(file); numberOfSelectedFiles++; createItem(file); } } } selectedFiles(numberOfSelectedFiles); } }
public void createTBOfflines() { List <Segment> segments = new List <Segment>(); if (!String.IsNullOrEmpty(path)) { try { foreach (string item in Directory.GetFiles(path)) { FileInfo fi = new FileInfo(item); string extension = fi.Extension; if (listfileextension.Contains(extension)) { if (extension == ".txt") { file a = new txtFile(); a.setFileName(fi.FullName); a.setdelimiters(delimiters); a.readContent(fi.FullName); segments.AddRange(a.getListSegments()); } if (extension == ".pdf") { file a = new pdfFile(); a.setFileName(fi.FullName); a.setdelimiters(delimiters); a.readContent(fi.FullName); segments.AddRange(a.getListSegments()); } if (extension == ".doc" || extension == ".docx") { file a = new wordFile(); a.setFileName(fi.FullName); a.setdelimiters(delimiters); a.readContent(fi.FullName); segments.AddRange(a.getListSegments()); } if (extension == ".pptx") { file a = new pptxFile(); a.setFileName(fi.FullName); a.setdelimiters(delimiters); a.readContent(fi.FullName); segments.AddRange(a.getListSegments()); } if (extension == ".xlsx") { file a = new excelFile(); a.setFileName(fi.FullName); a.setdelimiters(delimiters); a.readContent(fi.FullName); segments.AddRange(a.getListSegments()); } } } } catch (Exception) { } writeToTxt(segments); } }