Sonic.exe Download |link| | Simple ✭ |
// ------------------------------------------------------------- // Helper: get Content‑Length via HEAD request // ------------------------------------------------------------- private static async Task<long> GetContentLengthAsync(string url, CancellationToken ct) using var request = new HttpRequestMessage(HttpMethod.Head, url); using var response = await _http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, ct); response.EnsureSuccessStatusCode();
public partial class MainForm : Form
while ((read = await contentStream.ReadAsync(buffer.AsMemory(0, buffer.Length), ct)) > 0) await fileStream.WriteAsync(buffer.AsMemory(0, read), ct); totalRead += read; progress?.Report((totalRead, totalBytes)); sonic.exe download
public MainForm() InitializeComponent(); btnDownload.Click += BtnDownload_Click; using var response = await _http.SendAsync(request