C#中将文件保存为utf-8无bom格式

作者:管理员 更新时间:2014-03-03 13:10
///<summary>
///保存生成html页面到相应路径
///</summary>
///<param name="Shtml">要写入的内容</param>
///<param name="TemplatePath">存储路径</param>
///<returns></returns>
publicstaticvoid WriteHtmlFile(string Shtml, string HtmlPath)
{
  StreamWriter sw = null;
try
  {
      UTF8Encoding utf8 = new UTF8Encoding(false);
using (sw = new StreamWriter(HtmlPath, false, utf8))
      {
          sw.Write(Shtml);
      }
  }
catch
  {
thrownewException("存储路径错误,请检查路径" + HtmlPath + "是否存在!");
  }
finally
  {
      sw.Close();
  }
}


来源:亦有软件
软件产品Eysln Software Product
亦有公告Eysln Notice
案例中心Eysln Template
知识库Eysln Knowledge Base
工具箱Eysln Toolkit Online