I have a Dot Net MVC server that stores some zip files. I'm able to download these zip files successfully if I click on the hyperlink. However if I try to download the zip file using WebClient's DownloadFile, I'm able to download the zip file I get an error "Windows cannot open the folder, compressed zip folder is invalid"
Server side code :
public FilePathResult DownloadFile(int id)
{
string resultsdir = AppDomain.CurrentDomain.BaseDirectory + "Data\\ResultsDir\\" + res.RequestId.ToString();
string downloadFile = System.IO.Path.GetFileName(res.DownloadPath);
string zipPath = System.IO.Path.Combine(resultsdir, downloadFile);
return File(zipPath, "application/zip", downloadFile);
}
Client side I'm using Webclient to download this file
WebClient wc = new WebClient();
wc.DownloadFile("http://servername/Results/DownloadFile/853", "localspkgfile.zip");
If I download file by clicking hyperlink on browser, the filesize is 2.9 mb. However using webclient the file size is 5kb. Looks like WebClient is not able to download the file properly. Can anyone please suggest me a way to download the file.