views:

403

answers:

1

So I have this code below that creates a Directory and gives ASPNET permissions on the folder created. But when I run The Webclient.Downloadfile method, it says the folder created is still access denied..

Ive also just created a folder on C:/ and tried applying permissions my self and see what I get. But I still get access denied.

Can anyone help?

 DirectoryInfo di = Directory.CreateDirectory(path);
                    System.Security.AccessControl.DirectorySecurity dSec = di.GetAccessControl();
                    dSec.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule(@"LV38PCE00081461\ASPNET", System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow));
                    di.SetAccessControl(dSec);

Here is the Webclient.Download File Method im calling.
folderID is the the directory Exp: "C:\hello"

WebClient webClient = new WebClient();
webClient.DownloadFile(new Uri(reader.Value), folderID);
Console.WriteLine(folderID + " File Downloaded");

This Method above is what gives the Access denied.

On a Side note: This is a CONSOLE application... Its not a webpage or a web service.

+1  A: 

Is folderID the file that the data should be downloaded to or the folder that you want it downloaded to? It should be the file.

public void DownloadFile( Uri address, string fileName )

Parameters

address Type: System.Uri The URI specified as a String, from which to download data.

fileName Type: System.String The name of the local file that is to receive the data.

Brett Widmeier
folderID is the filename + the directory Exp: "C:\hello"
Scott
I wanted to say you pointed me in the Right direction!!! How could I be so stupid. fileName Type: System.String The name of the local file that is to receive the data. I totally missed this and was only describing the directory!
Scott