Similar to MSDN 6miu Navigation Tree Effect ASP.NET (C #) + JavaScript implementation!

zhaozj2021-02-08  306

Use this URL http: //localhost/webapplicationx/webform1.aspx to download in the Flashget

Switch pause / start, and add the downloaded block test!

Principle See the previous blog jsp / servlet Implementation

http://blog.cbs.net/playyuer/archive/2004/07/30/56538.aspx

Using this principle is not difficult to implement the download of the breakpoint to renew the multi-thread link of the database large field!

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 OnInit (Eventargs E) {// // Codegen: This call is an ASP.NET web form design The device is 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

}

转载请注明原文地址:https://www.9cbs.com/read-1105.html

New Post(0)