using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
namespace SpeedTest
{
class Program
{
static void Main(string[] args)
{
Console.Title = "A simple speedtest app";
Uri URL = new Uri("http://tv.vnn.vn");
WebClient wc = new WebClient();
Console.WriteLine("Welcome to this simple speedtest,\nwhich will test your download rate.");
Console.WriteLine("Press any key to begin.");
Console.ReadKey();
Console.WriteLine("\nDownloading file: 1024kb.txt...");
Console.WriteLine("From http://tv.vnn.vn");
Console.WriteLine("Note: This file will automatically be deleted after the test.");
double starttime = Environment.TickCount;
wc.DownloadFile(URL, @"C:\SpeedTest\SpeedTest\speedtest.txt");
double endtime = Environment.TickCount;
double secs = Math.Floor(endtime - starttime) / 1000;
double secs2 = Math.Round(secs, 0);
double kbsec = Math.Round(1024 / secs);
Console.WriteLine("\nCompleted. Statistics:\n");
Console.WriteLine("1mb download: \t{0} secs ({1} secs)", secs2, secs);
Console.WriteLine("Download rate: \t{0} kb/sec", kbsec);
Console.WriteLine("\nPress any key to exit...");
Console.Read();
Console.WriteLine("Cleaning up... (deleting downloaded file)");
try
{
System.IO.File.Delete(@"C:\SpeedTest\SpeedTest\speedtest.txt");
Console.WriteLine("Done.");
}
catch
{
Console.WriteLine("Couldn't delete download file.");
Console.WriteLine("To delete the file yourself, go to your C-drive and look for the file 'speedtest.txt'.");
Console.ReadKey();
}
}
}
}
[Edit]Code block added, 'C#' and 'services' tag added, 'to' tag removed[/Edit]