いくつかの zip ファイルを格納する Dot Net MVC サーバーがあります。ハイパーリンクをクリックすると、これらの zip ファイルを正常にダウンロードできます。ただし、WebClient の DownloadFile を使用して zip ファイルをダウンロードしようとすると、zip ファイルをダウンロードできますが、「Windows はフォルダーを開けません。圧縮された zip フォルダーが無効です」というエラーが表示されます。
サーバー側コード:
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);
}
クライアント側 Webclient を使用してこのファイルをダウンロードしています
WebClient wc = new WebClient();
wc.DownloadFile("http://servername/Results/DownloadFile/853", "localspkgfile.zip");
ブラウザでハイパーリンクをクリックしてファイルをダウンロードすると、ファイルサイズは 2.9 mb になります。ただし、webclient を使用すると、ファイル サイズは 5kb になります。WebClient がファイルを正しくダウンロードできないようです。ファイルをダウンロードする方法を教えてください。