C
C#4w ago
PIE

✅ File.WriteAllBytesAsync fails to download to bin folder with no error

This is the code I have currently
RestRequest request = new($"/d/{id}", Method.Get);
byte[]? response = await client.DownloadDataAsync(request);
//location is Path.Combine(Environment.CurrentDirectory, "Queue");
await File.WriteAllBytesAsync(location, response!);
Console.WriteLine($"{id} - {location} finished downloading");
RestRequest request = new($"/d/{id}", Method.Get);
byte[]? response = await client.DownloadDataAsync(request);
//location is Path.Combine(Environment.CurrentDirectory, "Queue");
await File.WriteAllBytesAsync(location, response!);
Console.WriteLine($"{id} - {location} finished downloading");
I'm assuming it's becuase the bin folder where the files are being downloaded to is being used by the application anyway to bypass this besides changing download locations? edit: seems to fail for all folders not just bin
3 Replies
PIE
PIE4w ago
this is a memory snapshot seems like the files are stuck in memory and not being written down? idk how thats possible though
No description
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
mindhardt
mindhardt4w ago
:thistbh: Better not download entire file to memory and just stream it directly into file Open a filestream to result file, open a stream of a web resource (with HttpClient.GetAsStreamAsync) and do source.CopyToAsync(dest)
Want results from more Discord servers?
Add your server