This uses the Dropbox .NET SDK to download a file from the Dropbox API at the remote path
to the local file "Test", while tracking progress:
var response = await client.Files.DownloadAsync(path);
ulong fileSize = response.Response.Size;
const int bufferSize = 1024 * 1024;
var buffer = new byte[bufferSize];
using (var stream = await response.GetContentAsStreamAsync())
{
using (var file = new FileStream("Test", FileMode.OpenOrCreate))
{
var length = stream.Read(buffer, 0, bufferSize);
while (length > 0)
{
file.Write(buffer, 0, length);
var percentage = 100 * (ulong)file.Length / fileSize;
// Update progress bar with the percentage.
// progressBar.Value = (int)percentage
Console.WriteLine(percentage);
length = stream.Read(buffer, 0, bufferSize);
}
}
}