public static string ReadFile(string filePath) { string fileContent = string.Empty; OfficeUtil util = null; FileInfo fi = new FileInfo(filePath); switch (fi.Extension.ToLower()) { case ".xml": case ".txt": case ".cs": case ".csv": fileContent = ReadTxtFile(filePath); break; //case ".doc": case ".docx": util = new WordUtil(); fileContent = util.Read(filePath); break; case ".xls": case ".xlsx": util = new ExcelUtil(); fileContent = util.Read(filePath); break; case ".ppt": case ".pptx": util = new PptUtil(); fileContent = util.Read(filePath); break; default: break; } return(fileContent); }