How do I display a file

I'm puzzled how to display a Word file on a window form.  I know I can create an instance of Word and display a file with Word, but all I want is a simple read-only window for the user to scroll through.  Is there a way to have an enlarged text box with a scroll bar for the user to look at a file?  That's all I really want (or something that would look like that).

Can you help?  Thanks.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


you can read the wordfile as any other file with the StreamReader object. Then you can display it in a RichTextBox. You can play with the RichTextBox properties on how it should handle scrollbars etc. I'll provide you with an example code that reads a file called "file.doc" into a richtextbox on a form. Good luck with it.

fs=New FileStream("file.doc",FileMode.Open,FileAccess.Read) 'file.doc can be, offcourse, any file you wish
'declaring a FileStream to open the file named file.doc with access mode of reading
Dim d as new StreamReader(fs)
'creating a new StreamReader and passing the filestream object fs as argument
'Seek method is used to move the cursor to different positions in a file, in this code, to
'the beginning
while d.peek()>-1
'peek method of StreamReader object tells how much more data is left in the file
RichTextbox1.Text &= d.readLine()
'displaying text from doc file in the RichTextBox
End while
Mike TomlinsonMiddle School Assistant TeacherCommented: could that possibly work?

A Word document is NOT a plain text file.  All the control characters embedded in the document that tell MSWord how to format that document would prevent it from being displayed properly.  The only way your code would work was if "file.doc" was actually a ".txt" file that has been renamed to a ".doc" file...
I use dsoframer....this embeds word or any other office application to my or c# form...
Pretty nice;en-us;311765

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.