Document Library Folder permissions with Dot Net

Hi,

i'm creating folder in the document library through ASP.Net. but i'm not able to access permissions for those folders through ASP.Net. i need to add users to that folder and remove permissions for particular user. can anyone help me out in this.

SPWeb Web =SPControl.GetContextWeb(Context);//This is the site where you want to add a folder

string str1 = Web.Url;

SPSite Site =newSPSite(str1+"//Virtual//");

Web = Site.OpenWeb();

Web.AllowUnsafeUpdates =true;

SPFolder rootFolder = Web.GetFolder("Virtual Hard Drive");//This is the root folder (document library folder).

rootFolder.SubFolders.Add(txtProjname.Text);

this is the code i've used to create folders.

[1453 byte] By [vikramvilasagaram] at [2008-1-1]
# 1

In my blog you will find a sample code that sets item security when items are uploaded. That should point you in the right direction.

Sample Event Handler to set Permissions

IshaiSagi at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Development and Programming...
# 2

Tanks Ishai,

i'm trying with the code you provided. Actually my requirement is. i have a document library Named as "Virtual hard Drive". and have folder named "Test" in that.

now i need to assign one user from my active directory to that perticular folder. and remove all other users to access that folder. i'm not able to point out the solution from your code for my requirement.

if the code u sent me will work for the current scenario, can u plzz guide me in that direction. i'm looking for this from last one month.

vikramvilasagaram at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Development and Programming...
# 3

The code I have there is almost exactly what you want, with one exception - it deals with a list item and not a folder item. but the objects should not be too different.

Ishai [MOSS MVP]

IshaiSagi at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Development and Programming...
# 4

In fact, they are different. SPListItem implements ISecurableObject, SPFolder does not.

But, SPFolder.Item is an SPListItem.

ArielK at 2007-9-12 > top of Msdn Tech,SharePoint Products and Technologies,SharePoint - Development and Programming...

SharePoint Products and Technologies

Site Classified