Link to home
Start Free TrialLog in
Avatar of camarotta
camarotta

asked on

webclient.downloadfile

Hi, I am trying to use webclient.downloadfile.  I have a virtual folder set up with a particular user.  The file is in the folder I want to download from, all is correct there, but when I try to download, I receive a "Not found" error.  I have tried a million settings but am about to give up.  The file is kind of big, so I don't know if that's an issue, but here's my code:  

sURL = sURL.Substring(0, sURL.LastIndexOf("/") + 1) & "p.db"
webfile = New WebClient
Dim mycache As CredentialCache = New CredentialCache
mycache.Add(New Uri(sURL), "Basic", New NetworkCredential("validuser", "validpassword"))
webfile.Credentials = mycache
webfile.DownloadFile(sURL, sPath & "p.db")

I just added the cache stuff today.  The user isn't really a basic user, it's added in under Anonymous Access.

Oh yes, I don't think this is using the default port, don't know if that matters.

Anyone know why I would get a file  not found error?

Thanks,
Carol
Avatar of nauman_ahmed
nauman_ahmed
Flag of United States of America image

The following will help:

WebClient.DownloadFile only see's Local????
http://www.codecomments.com/message508524.html

-Nauman.
Avatar of camarotta
camarotta

ASKER

thanks Nauman.  I don't think this is what I'm looking for though, I'm downloading from a url, not a filepath.  The URL is correct & the file is there.

Carol
OK, I'm making some progress on narrowing down the cause of the problem, has nothing to do with ports or proxy servers or anything like that.

I'm trying to download a sql db backup file.  It's not a standard type of MIME file.  I can download .txt files, and .xls files just fine and dandy, but not that backup file.  My theory is

1.  The file size, but I don't think that's it.
2.  The type of file it is

So is there a way to add a content type to the webclient?  I've tried to do webclient.Headers.Add("Content-Type", "application/x-msdownload") and things like that, but it's not helping.

Can anyone help me?

Thanks!
Carol
So, do I get points for answering my own question?  I just got this working this morning.  I went into IIS, to the Default Web properties and added the mim-type binary/octet-stream for files with a .db extension.  Worked unbelievably.

Carol
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial