client.DownloadProgressChanged += (s, e) => lblDownloadSize.Text = FormatBytes((client.ResponseHeaders["Content-Length"]).ToString());
And
private string FormatBytes(long bytes)
{
string[] Suffix = { "B", "KB", "MB", "GB", "TB" };
int i;
double dblSByte = bytes;
for (i = 0; i < Suffix.Length && bytes >= 1024; i++, bytes /= 1024)
{
dblSByte = bytes / 1024.0;
}
return String.Format("{0:0.00} {1}", dblSByte, Suffix[i]);
}
I want to display the file size either if it's in bytes or kb or mb or gb the problem is ResponseHeaders["Content-Length"] is long. And if I'm doing :
client.DownloadProgressChanged += (s, e) => lblDownloadSize.Text = Convert.ToInt64(client.ResponseHeaders["Content-Length"]).ToString();
It will just show the file size as one long number.