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.