Blog

How to read text from notepad?

Posted by Owais Khan Blogs | Files, Directory, IO Sep 21, 2010
How to read text from notepad in C#.
Download Files: how to open text.zip

This code snippet demonstrates how to read a text file and write text on a console.

using
System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

 

namespace convert_string_to_binery

{

    class Program

    {

        static void Main(string[] args)

        {

            TextReader tr = File.OpenText(@"E:\c#\ssdd.txt");

            Console.WriteLine(tr.ReadToEnd());

            tr.Close();

            Console.WriteLine(Console.Read());

        }

    }

}

post comment
     

This is good but TextReader had a better alternative StreamReader and you could dispose TextReader on the end!
:)

Posted by Josip Juric Sep 23, 2010

Keep it up , nice ......

Posted by Fareed Nizami Sep 22, 2010

Nice one article, keep it up 

Posted by Fareed Nizami Sep 22, 2010

hi...

how to display the text of text-file into a richtext box in windows application....

Posted by J R Sep 21, 2010
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts