Click here to Skip to main content
15,893,487 members

Comments by VivianMC (Top 2 by date)

VivianMC 12-Nov-15 6:11am View    
I know the following is probably too late to help you, but I'd like to add how this can be done so that if someone stumbles upon your question he can resolve it.

The problem is that you cannot read DOCX file like you would read simple text files, this is because DOCX file is actually a zipped group of files and folders.
But there is an article here on CodeProject that shows you how you can retrieve DOCX file's text content as a string, see:
Find Text in Word Documents

Alternatively you can use this C# component for word documents, it can process (read and write) DOCX files in C# and you could easily get its content as string like the following:

DocumentModel document = DocumentModel.Load("Sample.docx");
string s = document.Content.ToString();
VivianMC 11-Nov-15 5:57am View    
See the following link, I believe it's exactly what you want:
https://code.msdn.microsoft.com/windowsapps/Word-Document-Editor-in-d97fd70b

In short it's a sample application for a word document editor. It also uses a RichTextBox control, but additionally it uses this C# library for word documents as well. Now how it works is that any document that you want to open is first converted into an RTF format, that library is able to read your word files (both DOC and DOCX) in C# and write them in RTF formats with C#. Also when you want to save the RichTextBox content into a file, the library will read that RTF content and create the desired (for example PDF) file in C#.