Respons-File Download

Source: Internet
Author: User
From: http://www.cnblogs.com/PingFang/archive/2007/08/15/857009.html
UpdateName = Server. MapPath ("OnLoadDate \" + UpdateName); // download file path
FileInfo file = new System. IO. FileInfo (UpdateName );
Response. Clear ();

Response. Charset = "GB2312 ";

Response. ContentEncoding = System. Text. Encoding. UTF8;

// Add the header information and specify the default file name for the "download/Save as" dialog box

Response. AddHeader ("Content-Disposition", "attachment; filename =" + Server. UrlEncode (file. Name ));

// Add header information and specify the file size so that the browser can display the download progress.

Response. AddHeader ("Content-Length", file. Length. ToString ());

// Specify a stream that cannot be read by the client and must be downloaded.

Response. ContentType = "application/zip ";

// Send the file stream to the client

Response. WriteFile (file. FullName );

// Stop page execution
Response. End ();

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.