Access to the path is denied when programmatically downloading a file from ftp in C# on Win7 64bit

StackOverflow https://stackoverflow.com/questions/2187662

  •  25-09-2019
  •  | 
  •  

Question

I'm using the C# framework REBEX to download file(s) from an FTP on Win7 64bit in VS2008.

After I press F5 to start debugging, I get an error that Access to the path I'm downloading to is denied.

I believe this may be due to UAC and elevated permissions issues on Win7/Vista. I did some research and found some information on app.manifest, but when I change the requestedExecutionLevel in the app.manifest, it mentions that it isn't compatible with ClickOnce Security Settings. So I disabled ClickOnce only to have it automatically re-enable itself when building the project or debugging. And yes, I've enabled full security privileges for all users on the folder, and yes I've tried sending the files to my ...\AppData\Roaming\

Was it helpful?

Solution

Stupid me. Turns out I wasn't setting the full local filepath. Just to help anyone else in my predicament...

This will create an access denied exception:

client.GetFile(item.Name, @"C:\DIR\");

And this will get you the file you want:

client.GetFile(item.Name, @"C:\DIR\" + item.Name);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top