mirror of
https://github.com/Manu098vm/Switch-Gift-Data-Manager.git
synced 2026-04-25 07:52:22 -05:00
Increase Download Progress Prompt
This commit is contained in:
parent
eb0746a26d
commit
b70c300df0
|
|
@ -38,17 +38,31 @@ public partial class MgdbForm : Form
|
|||
Directory.CreateDirectory(path);
|
||||
|
||||
var zipPath = Path.Combine(path, "tmp.zip");
|
||||
using (var response = await client.GetAsync(url))
|
||||
using (var response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead))
|
||||
{
|
||||
var totalBytes = response.Content.Headers.ContentLength ?? 0;
|
||||
using (var content = await response.Content.ReadAsStreamAsync())
|
||||
using (var stream = new FileStream(zipPath, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
using (var stream = new FileStream(zipPath, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
var buffer = new byte[8192];
|
||||
int bytesRead;
|
||||
long totalRead = 0;
|
||||
while ((bytesRead = await content.ReadAsync(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
await content.CopyToAsync(stream);
|
||||
await stream.WriteAsync(buffer, 0, bytesRead);
|
||||
totalRead += bytesRead;
|
||||
// Calculate and display progress
|
||||
if (totalBytes > 0)
|
||||
{
|
||||
double progressPercentage = (double)totalRead / totalBytes * 100;
|
||||
// Update UI or log progress here
|
||||
lblMessage.Text = $"Download progress: {progressPercentage:F2}%";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ZipFile.ExtractToDirectory(zipPath, path);
|
||||
File.Delete(zipPath);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user