string strTemplate = Server.MapPath("Doctemplate.htm");
using (StreamReader sr = new StreamReader(strTemplate))
{
string content = sr.ReadToEnd().Replace("{$Content}", "我的内容");
using (System.IO.FileStream fs = new FileStream(Server.MapPath(System.DateTime.Now.ToString("HHmmss") + ".htm"), System.IO.FileMode.OpenOrCreate))
{
byte[] bs = System.Text.Encoding.GetEncoding("GB2312").GetBytes(content);
fs.Write(bs, 0, bs.Length);
}
}
using (StreamReader sr = new StreamReader(strTemplate))
{
string content = sr.ReadToEnd().Replace("{$Content}", "我的内容");
using (System.IO.FileStream fs = new FileStream(Server.MapPath(System.DateTime.Now.ToString("HHmmss") + ".htm"), System.IO.FileMode.OpenOrCreate))
{
byte[] bs = System.Text.Encoding.GetEncoding("GB2312").GetBytes(content);
fs.Write(bs, 0, bs.Length);
}
}
==========================================
你把"{$Content}"放到一个字符串里试试.
new StreamWriter(Server.MapPath("abc")+ "\\a.html",
true, System.Text.Encoding.UTF8,512);
swFromFileTrueUTF8Buffer.Write("你想输出的");
swFromFileTrueUTF8Buffer.Flush();
swFromFileTrueUTF8Buffer.Close();