I want to write an bandwidth speed test web app program.I used this method to test but it's only work perfectly fine for local host.Whene i upload my project to a web server,it doesn't work and give me access path denied because it tries to download and save the file on the webserver.I want to save this file on client machine.how can i fix this problem ?
public ActionResult download()
{
Uri URL = new Uri("http://mylink/myfile.pdf");
WebClient wc = new WebClient();
double starttime = Environment.TickCount;
wc.DownloadFile(URL, @"C:\speedtest.pdf");
double endtime = Environment.TickCount;
double secs = Math.Floor(endtime - starttime) / 1000;
double secs2 = Math.Round(secs, 0);
double kbsec = Math.Round(1024 / secs);
test t = new test();
try
{
System.IO.File.Delete("@C:\\speedtest.pdf");
t.kbps = kbsec;
t.message = "Done";
t.rTime = secs2;
t.time = secs;
}
catch
{
t.kbps = kbsec;
t.message = "File not deleted";
t.rTime = secs2;
t.time = secs;
}
return Json(t);
}