Unable to access file - WebClient.DownloadFile

Fishrock123 picture Fishrock123 · Apr 29, 2012 · Viewed 8.6k times · Source

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.

Answer

invulnarable27 picture invulnarable27 · Jan 30, 2013

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")