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) {// is not from the start of downloading, // responding is: // content-range: BYTES [Fault byte] - [Total size of files - 1] / [file Total size] Response.addheader ("Content-Range", "Bytes" P.toTRING () " ((long) ((l - p)). Tostring () " / " l.toString ());
Response.contentType = "Application / Oct-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 ();} #Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is the ASP.NET Web Form Designer Required. // initializeComponent (); base.onit (e);} ///// designer supports the required method - Do not use the code editor to modify the // / this method. ///
Private vidinitiRizeComponent ()
{
This.Load = New System.EventHandler (this.page_load);
}
#ndregion
}