[英]Create a html file and save in a folder
I'm making a asp.net project. 我正在制作一个asp.net项目。 I'm trying to send mail contains a html page in attachment.
我正在尝试发送包含附件中的html页面的邮件。 I m generating HTML code.
我正在生成HTML代码。 Now I want to write my HTML page and save it in a folder.
现在我想编写我的HTML页面并将其保存在一个文件夹中。 I checked in web and this site but didn't find the working codes.
我检查了网站和这个网站,但没有找到工作代码。
File.WriteAllText()
should do the Job File.WriteAllText()
应该执行Job
string content = GenerateHtml();
System.IO.File.WriteAllText(@"C:\yoursite.htm", content);
You can use HtmlTextWriter, something like this: 您可以使用HtmlTextWriter,如下所示:
StringWriter stringWriter = new StringWriter();
using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
{
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.