public static bool genearteHTML(DataRow dr,string fileName)
{
string path = HttpContext.Current.Server.MapPath("/news");
string html=fileName;
Encoding code = Encoding.GetEncoding("GB2312");
string temp = HttpContext.Current.Server.MapPath("/news/webs/template.html");
StreamReader sr = null;
StreamWriter sw = null;
string str = "";
try
{
sr = new StreamReader(temp, code);
str = sr.ReadToEnd();
str = str.Replace("@@newsTitle@@", dr[1].ToString());
str = str.Replace("@@newsDateTime@@", dr[3].ToString());
str = str.Replace("@@newsContent@@", dr[2].ToString());
str = str.Replace("@@newsSrc@@", dr[4].ToString());
}
catch (Exception exp)
{
HttpContext.Current.Response.Write(exp.Message);
HttpContext.Current.Response.End();
sr.Close();
}
try
{
sw = new StreamWriter(path+@"\html\"+fileName,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;
}