AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Syed Rizwan Muhammad Rizvi
Expertise
I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.

Experience
Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > My.Computer.Network.DownloadFile hangs a long time

Topic: VB.NET



Expert: Syed Rizwan Muhammad Rizvi
Date: 5/15/2006
Subject: My.Computer.Network.DownloadFile hangs a long time

Question
I have the following code in VB.NET:

       Dim t As DateTime

       t = Now
       My.Computer.Network.DownloadFile("http://www.google.nl", IO.Path.Combine(My.Application.Info.DirectoryPath, "google1.html"), "", "", False, 100 * 1000, True)
       Debug.WriteLine(CStr(Now.Subtract(t).TotalSeconds) & " sec.")

       t = Now
       My.Computer.Network.DownloadFile("http://www.google.nl", IO.Path.Combine(My.Application.Info.DirectoryPath, "google2.html"), "", "", False, 100 * 1000, True)
       Debug.WriteLine(CStr(Now.Subtract(t).TotalSeconds) & " sec.")

       t = Now
       My.Computer.Network.DownloadFile("http://www.google.nl", IO.Path.Combine(My.Application.Info.DirectoryPath, "google3.html"), "", "", False, 100 * 1000, True)
       Debug.WriteLine(CStr(Now.Subtract(t).TotalSeconds) & " sec.")

       Debug.WriteLine("")


I executed this code three times in a row and got this this debug-output:

       '12,6829146 sec.
       '0,100181 sec.
       '0,0500905 sec.

       '0,0801448 sec.
       '0,0500905 sec.
       '0,0601086 sec.

       '0,0601086 sec.
       '0,0500905 sec.
       '0,0601086 sec.


As you can see, the first download has a huge delay. After that, it goes smooth. If I repeat this like 5 minutes later, the first request is delayed again, but all requests after that are allways fast.

Why is this?

Answer
I hope you are not on Wireless LAN, seems more like a network problem to me than coding problem, it appears that the proxy caches the file after first download so your later downloads are faster, also the API's normally use IE's settings to connect to internet check to see if IE is set to discover proxy automatically, that can also be a cause of delay. really can only analyze the problem on your machine rather than anywhere else.

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.