C# Webclient Error

Krippleintime

Registered Member
Joined
May 12, 2010
Messages
96
Reaction score
13
When I try to run my program I keep getting an error saying that the webclient does not have permissions to the folder which I want to save the downloaded file. I have tried numerous folders, running the program as admin, and also running C# as admin, still the same error. Would I still get the error if I download the file through a Stream instead?

Here is my code:

Code:
WebClient client = new WebClient();
            client.DownloadFile(new Uri(dlurl), @"C:\");
            MessageBox.Show("Done");

Any help would be great, can't seem to find a fix to this.
 
client.DownloadFile(new Uri(dlurl), @"C:\");

This line has the issue, and I guess you are in vista or win7.

Change it to.


client.DownloadFile(new Uri(dlurl), @"C:\temp");
 
hmmm, I have seen to solve the problem with the error when I run it as admin, but now the file is not holding any data. This is what I changed it to:

Code:
client.DownloadFile(new Uri(dlurl), @"C:\file.exe");

And when I run it all I get is a CMD prompt which keeps popping up some weird errors.

Thanks for helping me with my main problem though!
 
Google around on the errors mate. Thats what all devs do. Cheers! :)
 
Try completely disabling UAC if you're on Vista or 7 and try again. Is this consistent on XP as well as 7?
 
Back
Top