string
mbPath
=
Server.MapPath(
"
htm/view_page.htm
"
);
Encoding code = Encoding.GetEncoding( " gb2312 " );
StreamReader sr = null ;
StreamWriter sw = null ;
string str = null ;
try
{
sr = new StreamReader(mbPath, code);
str = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
string fileName = DateTime.Now.ToString( " yyyyMMddHHmmss " ) + " .htm " ;
str = str.Replace( " $time$ " , " 123 " ); // 替换time
str = str.Replace( " $click$ " , " 123 " ); // 替换click
str = str.Replace( " $title$ " , " 123 " ); // 替换Title
str = str.Replace( " $content$ " , " 123 " ); // 替换content
try
{
sw = new StreamWriter(Server.MapPath( " htm/ " ) + fileName, false , code);
sw.Write(str);
sw.Flush();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sw.Close();
Response.Redirect( " htm/ " + fileName);
}
Encoding code = Encoding.GetEncoding( " gb2312 " );
StreamReader sr = null ;
StreamWriter sw = null ;
string str = null ;
try
{
sr = new StreamReader(mbPath, code);
str = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
string fileName = DateTime.Now.ToString( " yyyyMMddHHmmss " ) + " .htm " ;
str = str.Replace( " $time$ " , " 123 " ); // 替换time
str = str.Replace( " $click$ " , " 123 " ); // 替换click
str = str.Replace( " $title$ " , " 123 " ); // 替换Title
str = str.Replace( " $content$ " , " 123 " ); // 替换content
try
{
sw = new StreamWriter(Server.MapPath( " htm/ " ) + fileName, false , code);
sw.Write(str);
sw.Flush();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sw.Close();
Response.Redirect( " htm/ " + fileName);
}