|
-
November 11th, 2008, 12:15 PM
#1
DirectoryEntry for a single file
How can one set security on single file?
I'm trying to set the security permissions on an individual file on IIS. I've already used DirectoryEntry and it's Properties collection to set permissions at directory level but can't get it for file only, first of all I cannot new a DirectoryEntry with the url of a file, secondly if I new up a DirectoryEntry with the directory and then look for the Children it also fails, the debugger shows me an exception is thrown when trying to access the Children collection,
Code:
string myfileurl = url + "/myfile.asmx";
//if (DirectoryEntry.Exists(myfileurl))//fails
if (DirectoryEntry.Exists(url))
{
DirectoryEntry entry = new DirectoryEntry(url);
DirectoryEntry myfilesEntry = entry.Children.Find("myfile.asmx", "");//fails, Children throws an exception
PropertyCollection props = myfilesEntry.Properties;
Int32 currentValue = (Int32)props["AuthFlags"].Value;
entry.Properties["AuthFlags"][0] = 4;
entry.CommitChanges();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|