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();
}