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); } if (extension == ".xlsx" || extension == ".xls") { file a = new excelFile(); 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); } if (extension == ".pptx") { file a = new pptxFile(); a.setFileName(fi.FullName); string pathFileSave = Path.Combine(pathSaveFolder, a.getFileNameSave()); a.loadFileSave(pathFileSave); listFileOfSourceProject.Add(a); } } } } catch (Exception) { } } }
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); } }