Home > Backend Development > C#.Net Tutorial > How to download server files to local in asp.net

How to download server files to local in asp.net

高洛峰
Release: 2017-02-10 17:18:58
Original
2367 people have browsed it

This article mainly introduces the method of asp.net to download server files to local. Friends who need it can refer to

1. Instructions

Use the file download box to realize downloading files on the server Download the file to the local specified location. Here you need to specify the server file path

//服务器文件路径
string strFilePath = Server.MapPath("~") + "/excel/20170206104654.xlsx";
FileInfo fileInfo = new FileInfo(strFilePath);
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" + Server.UrlEncode(fileInfo.Name.ToString()));
Response.AddHeader("content-length", fileInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.WriteFile(strFilePath);
Copy after login

How to download server files to local in asp.net

How to download server files to local in asp.net

##The above is given by the editor The method you introduced to download server files to local using asp.net, I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!

For more asp.net related articles on the method of downloading server files to local, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template