请问如何自动生成一个html文件 我想把html里边某些标记字符 比如[news] 替换成数据库中取出来的字符 请问如何做 麻烦各位高手讲解下。。谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先读取模板页,然后用replace替换即可 使用模板替换public static bool WriteFile(string strText) { string path = HttpContext.Current.Server.MapPath("Html/"); System.Text.Encoding code = System.Text.Encoding.GetEncoding("gb2312"); string temp = HttpContext.Current.Server.MapPath("Html/A.html"); StreamReader sr = null; StreamWriter sw = null; string str = ""; try { sr = new StreamReader(temp, code); str = sr.ReadToEnd(); } catch (Exception exp) { HttpContext.Current.Response.Write(exp.Message); HttpContext.Current.Response.End(); sr.Close(); } string htmlfilename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html"; try { sw = new StreamWriter(path + htmlfilename, false, code); sw.Write(str); sw.Flush(); } catch (Exception ex) { HttpContext.Current.Response.Write(ex.Message); HttpContext.Current.Response.End(); } finally { sw.Close(); } return true; } 80分的简单,,散分啦 如何让程序歇一会? 这个c#怎么实现 如果确认选用的数据库不会更换,是否还有必要用三层? swfupload for asp.net 下载过来用vs怎么运行不了 很傻帽的问题,如何修改某个字段,使其值为空,o(∩_∩)o... 关于基础的多线程的问题 ACCESS数据库连接问题 ASP.NET连接MSSQL2000时出错? 兄弟们啊,兄弟们, 教我发封邮件吧........... 如何从datalist控件中取出一行数据的另一个字段值 DropDownList如何设置初始值
public static bool WriteFile(string strText)
{
string path = HttpContext.Current.Server.MapPath("Html/");
System.Text.Encoding code = System.Text.Encoding.GetEncoding("gb2312");
string temp = HttpContext.Current.Server.MapPath("Html/A.html");
StreamReader sr = null;
StreamWriter sw = null;
string str = "";
try
{
sr = new StreamReader(temp, code);
str = sr.ReadToEnd();
}
catch (Exception exp)
{
HttpContext.Current.Response.Write(exp.Message);
HttpContext.Current.Response.End();
sr.Close();
}
string htmlfilename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";
try
{
sw = new StreamWriter(path + htmlfilename, false, code);
sw.Write(str);
sw.Flush();
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
}
return true;
}