当前位置: 代码迷 >> ASP.NET >> 关于生成html页的有关问题(急)
  详细解决方案

关于生成html页的有关问题(急)

热度:9199   发布时间:2013-02-26 00:00:00.0
关于生成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已生成,但无法访问,提示a已被另一个进程使用.
请各位帮看看,谢谢!!!!

------解决方案--------------------------------------------------------
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();



}
  相关解决方案