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
Rich Bennema
2010-07-30 14:46:03
I don't permission to run code on an ASPX page on Sharepoint.
Rick
2010-07-30 19:04:14
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
2010-07-30 19:39:25
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_
2010-07-31 14:14:26
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
2010-08-02 13:34:11
I agree. Unless its just to eg display the year/date on a master page. :)
JWL_
2010-08-02 19:24:53
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
2010-08-03 05:21:03