Here's the class of my folder:
class MyFolder
{
private List<MyFolder> _folders;
public List<MyFolder> Folders
{
get
{
if (_folders == null)
{
_folders = new List<MyFolder>();
}
return _folders;
}
set
{
_folders = value;
}
}
public string Name { get; set; }
public string ContentType { get; set; }
}
So right now I have a root MyFolder which has five other MyFolders inside its "Folders" list, which in turn have their own MyFolders inside their "Folders" lists and so on and so on. This gives me a nice tree which I would like to upload into sharepoint.
So i have the context and create my document library to hold the folder structure like this:
static MyFolder root = new MyFolder();
private static void CreateLibrary(SPWeb web, string libTitle)
{
SPListTemplate listTemplate = web.ListTemplates["Document Library"];
SPDocTemplate docTemplate = (from SPDocTemplate dt in web.DocTemplates where dt.Type == 100 select dt).FirstOrDefault(); // 100 - no template
Guid guid = web.Lists.Add("MyLibrary","My folder structure", listTemplate, docTemplate);
var library = web.Lists[guid] as SPDocumentLibrary;
library.OnQuickLaunch = true;
library.ContentTypesEnabled = true;
library.Update();
CreateFolderStructure(); //this puts the folder structure inside 'root' object
UploadFolderStructure(root);
}
Now I'm looking for an easy implementation for the UploadFolderStructure method. If anybody has done anything like this before, help would be appreciated.