Pages

Saturday, 4 June 2011

StreamReader & StreamWriter classes in C#.Net.

2 comments
 
Hi friends,in this post i would like to explain StreamReader & StreamWriter classes in C#.Net.

* StreamReader is used to read data from the file.

* StreamWriter is used to write data into the file.
* Directly we are not write data into the file.First we should write into RAM & then through flush() it will be   written into the file.

StreamReader methods:

1)Read() : Reads single character.
2)ReadLine() : Reads single line.
3)ReadToEnd() : Reads full file.

For Example:

StreamReader str=new StreamReader(file1);
txtBox1.Text=str.ReadToEnd();
str.Close();


StreamWriter methods:

1)Write()
2)WriteLine()

For Example:

StreamWriter stw=new StreamWriter(file1);
stw.Write(txtBox1.Text);
stw.Flush();
stw.Close();

Note:

* Where file1 is the name of the file.


Thank You...
Shout it

2 Responses so far.

  1. really very very nice, add more interview question plz

  2. Anonymous says:

    Yes ! A baby steps guru.

Leave a Reply