using System;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
/**////
/// Summary description for HtmlProxy
///
public class HtmlProxy
...{
public HtmlProxy()
...{
}
public static bool ChangeFile(int id)
...{
string filename = ("Post_" + id + ".html");
//Try to read the existing file Stream st = GetFileStream(filename);
//If the file exists and the reading is successful
if (st != null)
...{
using (st)
...{
StreamToStream(st, );
return true;
//();
}
}
else
...{
StringWriter sw = new StringWriter();
("?PID=" + id, sw);
string content = ();
//Write into file
try
...{
using (FileStream fs = new FileStream(filename, , , ))
...{
using (StreamWriter stw = new StreamWriter(fs, ))
...{
(content);
}
}
return true;
}
catch ...{ return false; }
}
}
private static Stream GetFileStream(string filename)
...{
try
...{
DateTime dt = (filename);
TimeSpan ts = dt - ;
if ( >1)
...{
//Expiration in one hour
return null;
}
return new FileStream(filename, , , );
}
catch ...{ return null; }
}
static public void StreamToStream(Stream src, Stream dst)
...{
byte[] buf = new byte[4096];
while (true)
...{
int c = (buf, 0, );
if (c == 0)
return;
(buf, 0, c);
}
}
}
In the page file, the background code is as follows:
protected void Page_Load(object sender, EventArgs e)
...{
try
...{
int id = (["PID"]);
if((id))
...{
("Post_" + id + ".html");
}
else
...{
("?PID=" + id );
}
}
catch ...{
}
}