首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-03-01 
关于生成html页的问题(急急急)EncodingcodeEncoding.GetEncoding( gb2312 )StreamReadersrnullStrea

关于生成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();



}

热点排行