#region 根据字符串生成HTML静态页
///
/// 根据字符串生成HTML静态页
/// ///
html格式的字符
///
生成的HTML静态页路径
///
public static string WriteHtmlFile(string TemplateStr, string OutPutPath)
{
Encoding encoding = Encoding.GetEncoding("gb2312");
//StreamWriter实现一个 TextWriter,使其以一种特定的编码向流中写入字符,命名空间Syste.IO。
StreamWriter sw = null;
//生成的文件名
string newName = "AD.htm";
//写文件
try
{
sw = new StreamWriter(OutPutPath + newName, false, encoding);
sw.Write(TemplateStr);
//清理当前编写器的所有缓存区,并将缓存数据写入基础流。
sw.Flush();
}
catch (Exception e2)
{
MessageBox.Show(e2.Message);
}
finally
{
sw.Close();
sw.Dispose();
}
return newName;
}
#endregion
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23109131/viewspace-700346/
,如需转载,请注明出处,否则将追究法律责任。