ASP. NET breakpoint continued to pass

Source: Internet
Author: User

Using System;    Using System.Data;    Using System.Configuration;    Using System.Collections;    Using System.Web;    Using System.Web.Security;    Using System.Web.UI;    Using System.Web.UI.WebControls;    Using System.Web.UI.WebControls.WebParts;    Using System.Web.UI.HtmlControls;    Using System.IO;    Public partial class DFile:System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {}    protected void Linbtndfile_click (object sender, EventArgs e) {//Create a bit array byte[] buffer = new byte[10240];    Specifies the path to the file to download.    String filePath = @ "D:\-ji-ai-nook. rar";    Or take the file name including the extension string filename = Path.getfilename (FilePath);    Stream fileStream = null;    try {//Open file FileStream = new FileStream (FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);    Response.Clear ();    Gets the size of the file long fileSize = Filestream.length;    Long sum = 0; if (request.headers["Range"] = null) {Response.statuscode = 206;//indicates the HTTP output to return to the clientThe integer of the state.    The default value is 200. sum = long. Parse (request.headers["Range"). Replace ("bytes=", "").    Replace ("-", "")); } if (sum! = 0) {Response.AddHeader ("content-range", "bytes" + sum.) ToString () + "-" + ((long) (fileSize)).    ToString () + "/" + filesize.tostring ()); }//Get some HTTP header information Response.AddHeader ("Content-length", ((Long) (Filesize-sum)).    ToString ());    Response.ContentType = "Application/octet-stream"; Get the file source Response.AddHeader ("content-disposition", "attachment;    Filename= "+ Httputility.urlencode (Request.ContentEncoding.GetBytes (fileName));    Response.Flush (); filestream.position = sum;    Sets the current stream position fileSize = filesize-sum; When the file size is greater than 0 is entered into the loop while (FileSize > 0) {//Determines whether the client is still connected in the server if (response.isclientconnected) {//Get buffer    The total number of bytes.    int length = filestream.read (buffer, 0, 10240);    Write Data Response.OutputStream.Write (buffer, 0, length);    Sends the output of the buffer to the client Response.Flush ();    Buffer = new byte[10240]; FileSize = FileSize- Length    } else {//when the user disconnects and exits the loop fileSize =-1; }}} catch (Exception ex) {Response.Write ("Error:" + ex.)    Message);    } finally {if (FileStream! = null) {//Close file Filestream.close ();    } response.end (); }    }    }

  

ASP. NET breakpoint continued to pass

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.