Reading a text document in a visual studio project

I added a .txt file with a bunch of text to my project, now I need to read this file and print it to richtextbox.

How to find out how to access a file?

+5
source share
2 answers

You must put it in your resources, available under My Project> Resources. Select "Add Existing File" and import the text file. You can then access it as a string using the syntax Properties.Resources.<resource name>that you can assign to the RichTextBox property Text.

As an alternative to reading from a file, you can use System.IO.File.ReadAllTextit if you need all the contents as a string.

+7

, Copy to Output Directory true. File.ReadAllLines(filename) string[]. textBox.Text.

, @minitech.

+2

All Articles