I want to get my Download Speed, then i made this, but i'm getting this error.
"The name 'startTime1' does not exist in the current context"
What should I do
private void NetSpeed()
{
Uri url = new Uri("http://miranda.predialnet.com.br/downloads/ssu2.zip");
string destino = "NetSpeed.tmp";
WebClient Client = new
WebClient();
Client.DownloadFileAsync(url,
destino);
Client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
DateTime startTime1 = DateTime.Now;
}
private void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs
e)
{
int received = Convert.ToInt32(e.BytesReceived);
int received2 = received / 1024;
int total = Convert.ToInt32(e.TotalBytesToReceive);
int total2 = total / 1024;
if (received2 == total2)
{
DateTime stopTime1 = DateTime.Now;
TimeSpan duration1 = stopTime1 - startTime1;
double duracao =
duration1.TotalSeconds;
double
taxa = duracao / total2;
label1.Text = "duracao: " + stopTime1 + " Taxa:"
+ taxa;
}
}

passing parameters
Neelam
DateTime startTime1; // declare it in a global context
private void NetSpeed() {
Uri url = new
Uri("http://miranda.predialnet.com.br/downloads/ssu2.zip");
string destino = "NetSpeed.tmp";
WebClient Client = new WebClient();
Client.DownloadFileAsync(url, destino);
Client.DownloadProgressChanged += new
DownloadProgressChangedEventHandler
(client_DownloadProgressChanged);
startTime1 = DateTime.Now; // now it is just assigned a value
}
private void client_DownloadProgressChanged(object sender,
DownloadProgressChangedEventArgs e){
int received = Convert.ToInt32(e.BytesReceived);
int received2 = received / 1024;
int total = Convert.ToInt32(e.TotalBytesToReceive);
int total2 = total / 1024;
if (received2 == total2){
DateTime stopTime1 = DateTime.Now;
TimeSpan duration1 = stopTime1 - startTime1;
double duracao = duration1.TotalSeconds;
double taxa = duracao / total2;
label1.Text = "duracao: " + stopTime1 + " Taxa:" + taxa;
}
}
VijayTS