Guest User

Guest User

  • Tech Writer
  • 515
  • 46.4k

About Download code in mvc

Aug 3 2020 8:07 AM
hello Everyone,
Hope everyone is fine.
 
I am working in mvc and sql database.I am using following code to download a file, but it is giving "An exception occurred during a WebClient request" error or Sometimes "Given path format not supported" error.
 
The file is stored on Azure Storage and so it has online file url.
 
string remoteUri = "https://[Storagename].blob.core.windows.net/[ContainerName]/";
string fileName = [FileName], myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
myStringWebResource = remoteUri + [FileName];
Console.WriteLine("Downloading File \"{0}\" from \"{1}\" .......\n\n", [FileName], myStringWebResource);
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadFile(myStringWebResource, fileName);
 

Answers (3)