开发者

Creating a Folder in C#, Applying Permissions, But access is still DENIED?

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... I开发者_高级运维ts not a webpage or a web service.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜