How to take whole Html /xhtml file in single string to write?
I am new in c# , i开发者_StackOverflow 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.
string html = File.ReadAllText(@"C:\myhtmlfiles\index.html");
File.WriteAllText(@"c:\someotherfile.html", html);
Sure no problem. string foo = file.ReadToEnd()
.
string readPath= "D:\\Read.html";
string writePath= "D:\\write.html";
StreamReader sr = new StreamReader(readPath);
string html = sr.ReadToEnd();
StreamWriter sw = new StreamWriter(writePath);
sw.WriteLine(html);
or
string path = "D:\\Read.html";
string path1 = "D:\\write.html";
html=ReadAllText(path);
File.WriteAllText(path1, html);
精彩评论