?
Solved

Read Text File in Rich Text Box

Posted on 2004-11-30
1
Medium Priority
?
734 Views
Last Modified: 2008-03-17
How would I go about reading a text file, say "c:\test.txt" into a rich text box on a form?  
0
Comment
Question by:fattumsdad
1 Comment
 
LVL 3

Accepted Solution

by:
_kiwi_ earned 2000 total points
ID: 12706944
Hi,

Say you have a form of type Form1 (what a surprise !) and a richTexBox1 (gosh that's great).

You can put, in the load event (just dbl click on your form in the designer:

using(System.IO.StreamReader l_reader = new System.IO.StreamReader(@"c:\test.txt"))
{
   richTextBox1.Text = l_reader.ReadToEnd();
}

This does the trick.

If you want formatting or something more powerfull, it may be different, but for simple text, this is all you need.

Cheers,
Julien
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question