Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to access file - WebClient.DownloadFile

So I've looked for the answer multiple times, and meddled around with permission stuff to no avail, but this code still won't let me download a file to a specified path.

WebClient client = new WebClient();
client.DownLoadFile("http://dl.dropbox.com/u/(My account)/Installer.jar", @"c:\Games\Name\libs");
client.DownLoadFile("http://dl.dropbox.com/u/(My account)/Name.zip", @"c:\Games\Name");

Always gives me: "Access to the path 'c:\Games\Name\libs' is denied."

Also note, using windows XP SP3.

like image 764
Fishrock123 Avatar asked Apr 29 '12 03:04

Fishrock123


3 Answers

Hi I tried the above code locally and got the same error "Access is denied":

WebClient myWebClient = new WebClient();
    myWebClient.DownloadFile("http://localhost:1929/2.png", @"C:\Z\)

Try specifying the filename at the end of the directory, saves locally no problem when i ran it:

WebClient myWebClient = new WebClient();
    myWebClient.DownloadFile("http://localhost:1929/2.png", @"C:\Z\FILENAME.jpg")
like image 90
invulnarable27 Avatar answered Sep 23 '22 18:09

invulnarable27


The App probably doesn't have the permission to write to that folder. If this is a client app, try to run it as an administrator. Otherwise, change the permissions on 'c:\Games\Name\libs' to full control for everyone.

like image 43
tzerb Avatar answered Sep 19 '22 18:09

tzerb


If the access to there is denied try to run as administrator.

If it doesn't work, navigate to the folder C:\Games\Name\libs, right click it and go to Properties. Choose the "Security" tab, select at the top list the group of users that will run your program. (Try to use Users (YourName-PC\Users)). With it selected, click on Edit at the bottom of the list, and at the bottom list select Full control under Allow.

like image 35
MasterMastic Avatar answered Sep 20 '22 18:09

MasterMastic