asp.net| Multithreading | link | download
Using System;
Using System.Collections;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Web;
Using System.Web.SessionState;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.HtmlControls;
public class WebForm1:System.Web.UI.Page
{
private void Page_Load (object sender, System.EventArgs e)
{
string s = @ "E:\northwind.mdb";
s = @ "I:\\setupres\\sun\\j2re-1_4_2_05-windows-i586-p.exe";
System.IO.Stream s = new System.IO.FileStream (s, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
Long p = 0;
Long L = new System.IO.FileInfo (s). Length;
if (request.headers["Range"]!= null)
{
Response.statuscode = 206;
p = long. Parse (request.headers["Range"). Replace ("bytes=", ""). Replace ("-", ""));
}
Response.AddHeader ("Content-length", ((Long) (l-p)). ToString ());
if (P!= 0)
{
Not downloaded from the beginning,
The format of the response is:
content-range:bytes [File Block start byte]-[Total size of file-1]/[file Total size]
Response.AddHeader ("Content-range", "bytes" + p.tostring () + "-" + ((long) (l-p)). ToString () + "/" + l.tostring ());
}
Response.ContentType = "Application/octet-stream";
Response.AddHeader ("Content-disposition", "attachment; Filename= "+ System.IO.Path.GetFileName (s));
S.position = p;
int i = 1;
Byte[] B = new byte[1024];
while (i > 0)
{
i = S.read (b, 0, b.length);
Response.OutputStream.Write (b, 0, I);
}
S.close ();
Response.End ();
}
Code generated #region the Web forms Designer
Override protected void OnInit (EventArgs e)
{
//
CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
Base. OnInit (e);
}
///
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
///
private void InitializeComponent ()
{
This. Load + = new System.EventHandler (this. Page_Load);
}
#endregion
}