开发者

How to take whole Html /xhtml file in single string to write?

开发者 https://www.devze.com 2023-01-17 19:16 出处:网络
I am new in c# , i开发者_StackOverflow just want to know is it possible to take whole html document in a single string.

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消