Click here to Skip to main content
12,298,406 members (54,253 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET WCF
Dear Team,
I want to create a new folder. And Want to set permission in Read,Write,Inherit
for particular folder.

1. How to check read and write permission on a folder.
2. Dynamic count number of folder and file Exists.
3. On all Folder having Check box on front when user checked box that time given option set permission for Read, Write, Inherit folder.

Regards
Rohit Kumar Singh
9810353598
Posted 22-Nov-12 23:12pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Similiar Thread is Here[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

static void Main(string[] args)
{
string directory = @"C:\Folder_name";

DirectoryInfo di = new DirectoryInfo(directory);

DirectorySecurity ds = di.GetAccessControl();

foreach (AccessRule rule in ds.GetAccessRules(true, true, typeof(Data)))
{
Console.WriteLine("Identity = {0}; Access = {1}",
rule.IdentityReference.Value, rule.AccessControlType);
}
}


Regards,
Praveen Nelge
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Full access control to folder or directory
private static void SetPermissions(string dirPath)
{
    DirectoryInfo info = new DirectoryInfo(dirPath);
    WindowsIdentity self = System.Security.Principal.WindowsIdentity.GetCurrent();
    DirectorySecurity ds = info.GetAccessControl();
    ds.AddAccessRule(new FileSystemAccessRule(self.Name, 
    FileSystemRights.FullControl,
    InheritanceFlags.ObjectInherit |
    InheritanceFlags.ContainerInherit,
    PropagationFlags.None,
    AccessControlType.Allow));
    info.SetAccessControl(ds);
}
  Permalink  
Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 18 Jan 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100