hi
I design download website that use temporary link for this website that users with this link can download their files below are codes
protected void Page_Load(object sender, EventArgs e)
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand _cmd = General.GetCommand("Downloadurl", conn))
{
string downloadtoken = Page.RouteData.Values["downloadtoken"].ToString();
_cmd.Parameters.AddWithValue("@DownLoadToken", downloadtoken);
conn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
while (_dr.Read())
{
if (Convert.ToDateTime(_dr["ExpiryDate"]) < DateTime.Now)
{
Response.Redirect("~/DownloadError.aspx");
}
string path = Server.MapPath(_dr["Url"].ToString());
FileStream fs = File.OpenRead(path);
byte[] fileData = new byte[fs.Length];
fs.Read(fileData, 0, (int)fs.Length);
Response.Clear();
Response.AddHeader("Content-Type", "application/zip");
Response.AddHeader("Content-Disposition", "inline;filename=" + Path.GetFileName(path));
Response.BinaryWrite(fileData);
Response.Flush();
Response.Close();
}
}
}
now I want limit download speed for link according below thread
http://www.aspforums.net/Threads/118428/how-I-can-limit-download-speed-in-IIS/
string outputFileName = "Learning-ICDL(www.rasekhoon.net).rar";
string filePath = Server.MapPath("~/download file/Learning-ICDL(www.rasekhoon.net).rar");
string value = ddlDonwloadSpeed.SelectedValue;
int downloadSpeed = 1024 *10;
Response.Clear();
try
{
DownloadFileWithLimitedSpeed(outputFileName, filePath, downloadSpeed);
}
catch (Exception ex)
{
Response.Write(@"<p><font color=""red"">");
Response.Write(ex.Message);
Response.Write(@"</font></p>");
}
Response.End();
now how I can merg above code with first code ?
can you help me?
Best regards
Neda