C#C
C#13mo ago
10 replies
Core

✅ Downloading file with HttpClient does not work

Hello,

Everywhere it is advisable to use HttpClient for downloading larger files.
For some reason it only downloads a little chunk of a larger file, and that's it. How should I even determine what the problem is?

The url is fine, I am able to download the file trough the browser

await using var stream = await httpClient.GetStreamAsync(_url);
await using var fileStream = new FileStream(filePath, FileMode.Create);
await stream.CopyToAsync(fileStream);
Was this page helpful?