public void ReadFileContent(string path) { string ext = Path.GetExtension(path); if (ext == ".doc") { try { Word2pdf w2p=new Word2pdf(); pathToPdf= w2p.ConvertToPdf(path); ReadPdf(pathToPdf); } catch (COMException) { MessageBox.Show("Unable to read this document. It may be corrupt."); } } else { ReadPdf(path); } }
public void ReadFileContent(string path) { string ext = Path.GetExtension(path); if (ext == ".doc") { try { //var wordApp = new ApplicationClass(); //object file = path; //object nullobj = System.Reflection.Missing.Value; //Document doc = wordApp.Documents.Open( // ref file, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj); //doc.ActiveWindow.Selection.WholeStory(); //doc.ActiveWindow.Selection.Copy(); //IDataObject data = Clipboard.GetDataObject(); //DocText.Text = data.GetData(DataFormats.Text).ToString(); //doc.Close(ref nullobj, ref nullobj, ref nullobj); //wordApp.Quit(ref nullobj, ref nullobj, ref nullobj); Word2pdf w2p=new Word2pdf(); pathToPdf= w2p.ConvertToPdf(path); ReadPdf(pathToPdf); } catch (COMException) { MessageBox.Show("Unable to read this document. It may be corrupt."); } } else { ReadPdf(path); } }