日期:2014-05-20  浏览次数:20537 次

关于生成html页的问题(急急急)
Encoding   code   =   Encoding.GetEncoding( "gb2312 ");
StreamReader   sr   =   null;
StreamWriter   wr   =   null;
string   str   =   " ";
try
{
sr   =   new   StreamReader(path+temp,code);
str   =   sr.ReadToEnd();
}
catch(Exception   exp)
{
HttpContext.Current.Response.Write( "error "+exp.Message);
HttpContext.Current.Response.End();
sr.Close();
}
str   =   str.Replace( "aaa ",ne);
try
{
wr   =   new   StreamWriter(htmlf+htmlname,false,code);
wr.Write(str);
wr.Flush();
}
catch(Exception   ex)
{
HttpContext.Current.Response.Write( "error "+ex.Message);
HttpContext.Current.Response.End();
wr.Close();


}
try
{
sr   =   new   StreamReader(temp,code);
str   =   sr.ReadToEnd();
}
catch(Exception   exp)
{
HttpContext.Current.Response.Write( "error "+exp.Message);
HttpContext.Current.Response.End();
sr.Close();
}
str   =   str.Replace(ne, "aaa ");
return   htmlname;
代码如上,a.html已生成,但无法访问,提示a.html已被另一个进程使用.
请各位帮看看,谢谢!!!!

------解决方案--------------------
try
{
wr = new StreamWriter(htmlf+htmlname,false,code);
wr.Write(str);
wr.Flush();
wr.Close();
}
catch(Exception ex)
{
HttpContext.Current.Response.Write( "error "+ex.Message);
HttpContext.Current.Response.End();



}