Using Stream Reader and Stream Writer (C#)
Example using Stream Reader
string File = Server.MapPath("/test/test.html");
StreamReader sr = new StreamReader(File);
string sreader = sr.ReadToEnd();
sr.Close();
Explanation :
It used to read string until the end of file test.html in a virtual directory “/test/test.html”
Example using Stream Writer
string directory = "C:\\Documents and Settings\\riani\\Desktop\\TESPDF\\TESPDF\\TESPDF\\test";
StreamWriter sWriter = File.CreateText(directory + "\\name.html");
sWriter.Write(sreader);
sWriter.Close();
Explanation :
It used to write string, which result of stream reader before, to a new created file at the certain directory and a file named as name.html.
Notice that after finished using both streams, don’t forget to close it.