關於在Asp
一個是一個頁面轉換的類
using System;
using System
using System
using System
using System
using System
using System
using System
using System
using System
using System
/**//// <summary>
/// Summary description for HtmlProxy
/// </summary>
public class HtmlProxy
public HtmlProxy()
}
public static bool ChangeFile(int id)
string filename = HttpContext
//嘗試讀取已有文件
Stream st = GetFileStream(filename);
//如果文件存在並且讀取成功
if (st != null)
using (st)
StreamToStream(st
return true;
//Response
}
}
else
StringWriter sw = new StringWriter();
HttpContext
string content = sw
//寫進文件
try
using (FileStream fs = new FileStream(filename
using (StreamWriter stw = new StreamWriter(fs
stw
}
}
return true;
}
catch
}
}
private static Stream GetFileStream(string filename)
try
DateTime dt = File
TimeSpan ts = dt
if (ts
//一小時後過期
return null;
}
return new FileStream(filename
}
catch
}
static public void StreamToStream(Stream src
byte[] buf = new byte[
while (true)
int c = src
if (c ==
return;
dst
}
}
}
在頁面文件中
protected void Page_Load(object sender
try
int id = int
if(HtmlProxy
Response
}
else
Response
}
}
catch
}
}
From:http://tw.wingwit.com/Article/program/net/201311/14656.html