I am new in c# , i just want to know is it possible to take whole html document in a single string. i even want to write it in another file.
Thanx in advance.
I am new in c# , i just want to know is it possible to take whole html document in a single string. i even want to write it in another file.
Thanx in advance.
Hi, its very simple, i have given 2 ways to implement this way 1
string path = "D:\\Read.html";
string path1 = "D:\\write.html";
StreamReader sr = new StreamReader(path);
string html = sr.ReadToEnd();
StreamWriter sw = new StreamWriter(path1);
sw.WriteLine(html);
way 2
string path = "D:\\Read.html";
string path1 = "D:\\write.html";
html=ReadAllText(path);
File.WriteAllText(path1, html);
But i ll prefer 2nd way cheers !!
string html = File.ReadAllText(@"C:\myhtmlfiles\index.html");
File.WriteAllText(@"c:\someotherfile.html", html);