Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a web part that need to have its own document library. Is there any way for me to check to see if that document library exists and if not create it, when the WSP is installed?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Yes, you would do this via a Feature Receiver for the Feature that deploys the web part.

For more information on creating a Feature Receiver see: http://msdn.microsoft.com/en-us/library/ff872401.aspx#InsideSP14_Ch3_AAFR

Here's a simple example that shows how to create a document library in code: http://www.eblogin.com/eblogin/post/2011/03/15/sp-CreateDocLibrary.aspx

share|improve this answer
    
I tried to add this to the FeatureActivated event but it says SPContext.Current.Site is null. Should i be doing this somewhere else? –  Abe Miessler May 7 '11 at 15:47
    
Nevermind, I found a solution for that here: chakkaradeep.com/post/… –  Abe Miessler May 7 '11 at 15:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.