Tuesday, October 20, 2009

How to Read and Write to File using FileStream

The FileStream class is derived from Stream class. This class can be used for reading from and writing to files such as bytes, characters, strings, and other data-type values to a file. Other class I have used in this sample is StreamWriter. The StreamWriter class's Write and WriteLine members write to a file.

In this sample code, I have used FileStream class to create a text file and StreamWrite to write text to the text file. StreamRead to Read from the text File

First Of all design the Form as following Picture.




And then Do the Following Codings on button click events