RE: WebClient and File Download

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

Do you mean that directly calling
WebClient.DownloadFileAsync("http://www.sample.com/mydir/myfile.csv";,
"c:\1.csv") will fail with 404?

That's strange if the URL really exists. Please try if following code works
on your side:

Imports System.Net
Imports System.ComponentModel

Module Module1

Sub Main()
Dim wc As New WebClient()
AddHandler wc.DownloadFileCompleted, AddressOf
wc_DownloadFileCompleted
wc.DownloadFileAsync(New
Uri("http://msdn2.microsoft.com/default.aspx";), "c:\temp\1.txt")
Console.Read()
End Sub

Sub wc_DownloadFileCompleted(ByVal sender As Object, ByVal e As
AsyncCompletedEventArgs)
Console.WriteLine("Done")
End Sub

End Module

As you can see, the code is simple. If the URL exists and you're actually
able to download the root document, I don't see why it fails.


Regards,
Walter Wang (wawang@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • Re: Sub routine syntax errors
    ... If you are trying to run this from another module it will fail. ... Sub btnRunThis_OnClick ... Dim db as CurrentDB ... Dim varItem as Variable ...
    (comp.databases.ms-access)
  • A Better way to Run Scripts in Rule Wizard
    ... You may note that I posted before "Funky Errors running scripts from ... Public Sub Application_Startup ... ' Check to make sure it is an Outlook mail message, ... ' subsequent code will probably fail depending on what type ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Why does this simple Sub fail?
    ... You have option explicit and failed to dim ... > Private Sub WorkBook_Open ... > The failure occurs on the line marked 'Fail 1 ... > Worksheet "Main" exists, is not hidden and is on top at open. ...
    (microsoft.public.excel)
  • RE: Conditional formatting with merged cells
    ... Sub Fail() ... are four separate cells, D1:D4 are four separate cells, etc., etc. ...
    (microsoft.public.excel.programming)
  • RE: XP Generic Host Process Error and Internet failure
    ... > I am having several strange problems with my windows XP and I ... > think these problems are the reason that my internet connection fails ... > after some time my internet does fail ... > spyware program or Bitlord… that’s basically all that I changed. ...
    (microsoft.public.windowsxp.help_and_support)