开发者

Converting HTML file into c# as string

开发者 https://www.devze.com 2022-12-29 18:54 出处:网络
I am looking for a way to design a simple HTML file, and in runtime - to load it as string to the c#.

I am looking for a way to design a simple HTML file, and in runtime - to load it as string to the c#.

I am trying to File.Open it, but it resides in a different location than the binary code.

is there a simple w开发者_开发知识库ay to tell the build process to load it into a string?

thanks


If you're using ASP.NET, and the HTML file is relative to your website path:

string html = File.ReadAllText(Server.MapPath("~/virtualPathTo/file.html"));


If the HTML is on another server, the easiest thing to do is use the HTTPWebRequest class to get the HTML.


Ok. I used RESOURCES to load a file, and it converted to be a string... :)

thanks all

0

精彩评论

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