views:

45

answers:

2

I need to create a folder in the root directory of Sharepoint 2007.

+2  A: 
SPContext.Current.Site.RootWeb.Folders.Add("MyFolder");

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfoldercollection%28office.12%29.aspx

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfoldercollection.add%28v=office.12%29.aspx

Rich Bennema
I don't permission to run code on an ASPX page on Sharepoint.
Rick
That's correct. Code needs to be in a DLL and cannot be inline on an ASPX page. You can also create a folder using SharePoint Designer. If DLLs and SharePoint Designer aren't options, I'd suggest editing your question with more detail as to what you are trying to accomplish and what options are/are not available to you.
Rich Bennema
Thats not correct. You can run code in aspx pages. You need to modify the web.config file with the path to the page.PageParserPaths -> <PageParserPath VirtualPath=”/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />
JWL_
Let me restate: code should be in a DLL and not inline on an ASPX page. Yes, code can be placed inline if it's in _layouts or with a web.config modification, but the best practice is to place code into a DLL.
Rich Bennema
I agree. Unless its just to eg display the year/date on a master page. :)
JWL_
I'd just as soon add the folder using the command you recommend, but in PowerShell, so long as this folder creation is a one-off thing. Not much point in deploying a whole .DLL for a tiny task such as this unless it is intended to be configurable and repeatable.
kbrimington
A: 

Used Sharepoint Designer to create folder.

Rick