Kiran's personal website
Blog    Forums   Sitemap   Social    Phone

Knowledge base home, and site home.
List of all Knowledge base categories.
An alphabetical list of technical terms.
Contact Me
Contact me for knowledge base questions
My Blog
My articles, white papers, ideas and thoughts.


Read Text File

Date Added March 4, 2010 | Print | Bookmark

//Reading Text Files

//Use the using directive
using System.IO;

//With Text Reader

TextReader tr = File.OpenText(@"C:\yourFile.txt");

string fileContent = tr.ReadToEnd();


//With Stream Reader

StreamReader sr = new StreamReader(@"C:\yourFile.txt");

StringBuilder fileContent = new StringBuilder();

string input;

while ((input = sr.ReadLine()) != null)



Was this article helpful?

Yes No

Category: C#.NET- I/O

Last updated on March 4, 2010 with 3915 views


Home | About Me | Products | Support | Contact | Knowledgebase | Forums | Blog | Site map | Site Search | Subscribe | Links | Social | News

Travel | Guest Book | All Pages | History | Site Calendar | Recipes | Ex-Rates | UK Stuff | Downloads | Telugu Stuff | Tell a Friend | Feedback

Bookmark and Share
Terms of Use
Site contents Copyright © 2008-2009 Kiran Reddy. All rights reserved.