butten按钮下
string html = @"<html><head></head><body><font size=" + "2" + " >"呆呆的</font></body></html>";
string fileName = WriteFile(html, "D:\\");
public static string WriteFile(string TemplateStr, string OutPutPath)
{
Encoding encoding = Encoding.GetEncoding("gb2312");
//StreamWriter实现一个 TextWriter,使其以一种特定的编码向流中写入字符,命名空间Syste.IO。
StreamWriter sw = null;
//生成的文件名
string newName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";
//写文件
try
{
sw = new StreamWriter(OutPutPath + "aaaa.html", false, encoding);
sw.Write(TemplateStr);
//清理当前编写器的所有缓存区,并将缓存数据写入基础流。
sw.Flush();
}
catch (Exception )
{
//MessageBox.Show(e2.Message);
}
finally
{
sw.Close();
sw.Dispose();
}
return newName;
}