This article is a mirror article of machine translation, please click here to jump to the original article.

View: 26973|Reply: 0

[Source] .NET/C# Use the WebClient download to complete the file name

[Copy link]
Posted on 8/22/2020 9:48:56 AM | | | |
Using the WebClient class provided by Microsoft, you can easily download files through the specified URL link, if we don't want to customize the download file name to save to the local area, the original name of the file sent by the server will be stored locally, this article will explain in detail.

ASP.NET Download


WebClient download the file

Principle: To obtain the server download file name, you can actually get the content of Content-Disposition in the response header.



When calling DownloadFileAsync to download, first define a local storage path and file name, and get the file name returned by the server after the download is completed, the code is as follows:







Previous:SRDescriptionAttribute makes your control property annotations multilingual
Next:Explanation of C# 8.0 new features and knowledge points
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com