Home > Article > Backend Development > How to download server files to local in asp.net
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);##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!