开发者

Converting HTML file into c# as string

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜