开发者

how to load html code into c# string?

开发者 https://www.devze.com 2023-01-19 05:59 出处:网络
HI, I\'ve got a really seriously question. I need to send HTML code, so I have to load html into string, an开发者_运维知识库d this obvious doesn\'t work if I can\'t interpret them well, how can I sto

HI, I've got a really seriously question.

I need to send HTML code, so I have to load html into string, an开发者_运维知识库d this obvious doesn't work if I can't interpret them well, how can I store it natively?

Thanks for your help


Strings and HTML should be fine. The only complication is escaping, which is made easier using verbatim string literals (@"..."). Then you just double any double-quotes:

string body = @"<html><body>
<a href=""foo.bar"" class=""blap"">blip</a>
...
</body></html>";


If you html code is in a file you can File.ReadAllText

string myString = System.IO.File.ReadAllText("path to the file");
0

精彩评论

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