Calin Tatar

C#.NET, VB.NET, SQL, WSS, MOSS
posts - 5, comments - 4, trackbacks - 0

My Links

News

Archives

Post Categories

C#.NET

Links

VB.NET

Automatically add Sharepoint subfolders when adding a new Folder Content Type

Last week I was asked on one of my CodeProject article, about how to implement a Sharepoint feature that will automatically add subfolders to a parent folder in a document library.

To add subfolders when a new Folder(or derived Content Type from Folder) was created, we have to write a feature, that will handle the ItemAdded event. When this event gets fired, we can get the current folder item and add subfolders to it.

The following feature adds subfolders( the ones from folders array) when a new Project Folder is created.

SubFoldersCreatorFeature

Basically, what the above method is doing is:

- we get the current document library that we are working on.

- test if the current Item is derived from our Content Type; with this we can restrict the feature to work only on some of the folder content types

- by getting the url of the current folder, we can add a new folder on the current SPDocumentLibrary.

Enjoy!

Calin Tatar

Print | posted on Sunday, June 07, 2009 4:48 AM | Filed Under [ UI Automation MOSS 2007 WSS 3.0 ]

Feedback

Gravatar

# re: Automatically add Sharepoint subfolders when adding a new Folder Content Type

what program is the code created in ?
7/20/2009 7:44 PM | Mike Brickles
Gravatar

# re: Automatically add Sharepoint subfolders when adding a new Folder Content Type

Hi Mike,

It was Visual Studio 2005, class library project, referencing Sharepoint API, deployed as SP feature.

Calin
7/21/2009 1:00 AM | Calin Tatar
Gravatar

# Mr

I really want to thank you for the code.
However since its a #$%^& screenshot I would have to retype it all. So I shall continue my googles and come back if I fail, prepared for the typing.
10/6/2009 11:25 AM | Yan Herndon
Gravatar

# re: Automatically add Sharepoint subfolders when adding a new Folder Content Type

I could paste the code here if you want.

Calin
10/8/2009 10:06 AM | Calin
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: