Here is the snippet of how to Create Folder in Document Library programmatically using the Object Model. It can be used in console applications for loading documents or timer-jobs.
string spsiteUrl = "http://spdev/";
string spwebUrl = "forum/";
string folder = "folder";
using (SPSite spsite = new SPSite(spsiteUrl))
{
using (SPWeb spweb = spsite.OpenWeb(spwebUrl))
{
SPFolder doclibFolder = spweb.Folders["DocLib"]; // Doclib is the URL name of document library
SPFolder childFolder = doclibFolder.SubFolders.Add(folder);
}
}
Leave a Reply