Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

StreamReader

 

Use the System.IO.StreamReader class. It has a constructor which takes a filename and has a ReadToEnd() method which will return the entire contents of the file in a string.

 

Good luck :)

Never trouble another for what you can do for yourself.
  • Leaders
Posted

Re: StreamReader

 

An easier way would be to use the ReadAllText method of the File class.

[color="Magenta"]C#[/color]
[color="Blue"]string[/color] text = System.IO.File.ReadAllText(filename);

[color="Magenta"]VB[/color]
[color="Blue"]Dim [/color]Text [color="Blue"]As String [/color]= System.IO.File.ReadAllText(Filename)

[sIGPIC]e[/sIGPIC]
Posted

Re: StreamReader

 

An easier way would be to use the ReadAllText method of the File class.

[color="Magenta"]C#[/color]
[color="Blue"]string[/color] text = System.IO.File.ReadAllText(filename);

[color="Magenta"]VB[/color]
[color="Blue"]Dim [/color]Text [color="Blue"]As String [/color]= System.IO.File.ReadAllText(Filename)

 

This is (as quoted from MSDN) "new in the .NET Framework version 2.0".

Amir Syafrudin

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...