Skip to content

Instantly share code, notes, and snippets.

@harshityadav95
Created August 18, 2017 12:30
Show Gist options
  • Save harshityadav95/287a2791a05fed6eb35221e4c438fb6a to your computer and use it in GitHub Desktop.
Save harshityadav95/287a2791a05fed6eb35221e4c438fb6a to your computer and use it in GitHub Desktop.
code 2
//metroLabel16.Text = "Running";
System.Net.WebClient wc = new System.Net.WebClient();
//DateTime Variable To Store Download Start Time.
DateTime dt1 = DateTime.Now;
//Number Of Bytes Downloaded Are Stored In ‘data’
byte[] data = wc.DownloadData("https://github.com/harshityadav95/static-file-storage/blob/master/text.txt");
//DateTime Variable To Store Download End Time.
DateTime dt2 = DateTime.Now;
//To Calculate Speed in Kb Divide Value Of data by 1024 And Then by End Time Subtract Start Time To Know Download Per Second.
double r = Math.Round((dt2 - dt1).TotalSeconds, 2);
// double r = (data.Length / 1024) / (dt2 - dt1).TotalSeconds;
// Download code freeze
return r;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment