Keep the file download custom connection supports FlashGet breakpoint loop multi-thread link download! C #asp.net implementation

zhaozj2021-02-16  103

Use this URL http: //localhost/webapplicationx/webform1.aspx to download the switch / start in the flashget, and add the downloaded block test! Principle See the previous Blog JSP / Servlet Implementation: http://blog.9cbs .NET / PLAYYUER / ARCHIVE / 2004/07/30 / 56538.ASPX Using this principle It is not difficult to implement a breakpoint of the breakpoint of the database large field to renew multi-thread link! use system; use 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 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.filecess.read, system.io.fileshare. Read); Long P = 0; long l = new system.io.fileinfo (s) .length; response.addheader ("accept-ranges", "bytes"); if (Request.Headers ["Range"]! = NULL) {response.statuscode = 206; p = long.parse (Request.Headers ["Range"]. REPLA CE ("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 [File Block Start byte] - [Total Size of File - 1] / [File Total size] Response.addheader ("Content-Range", "Bytes" P.Tostring () " ((l - p)). Tostring () " / " l.toString ));} Respternse.contentType = "Application / OCTET-stream"; response.addhead ("content-disposition", "attachment; filename =" system.io.path.getFileName (s)); 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 required for the ASP.NET Web Form Designer. // InitializationComponent (); base.onit (e);} /// // / designer supports the required method - do not use the code editor to modify the // / this method. /// private vid initializeComponent () {this.load = new system.eventhandler (this.page_load);} #endregion}

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

New Post(0)