Sharepoint 2010 DocumentSets - How to Manage Programatically? -


i new sharepoint 2010 not new .net programming. here situation, have large set of files uploaded sharepoint 2010 metadata. have decided write c# class library handle documentsets programatically. have use documentsets , able create documentset. stuck following:

  1. how check if documentset exists?
  2. how remove documentset?

here code create documentset:

using (spsite site = new spsite(spurl)) {     using (spweb web = site.openweb())     {         splist docs = web.lists["documents"];          if (docs != null)         {             spcontenttype docsetct = docs.contenttypes["document set"];              if (docsetct != null)             {                 hashtable docsetprops = new hashtable();                 docsetprops.add("new docset", "new docset");                 documentset docset = documentset.create(docs.rootfolder, documentsetname, docsetct.id, docsetprops, true);                 docs.update();             }         }     } } 

the list of helper methods working document sets:

how check if document set exists?

private static bool isdocumentsetexist(splist list,string docsetname) {     var folderurl = spurlutility.combineurl(list.rootfolder.serverrelativeurl, docsetname);     var folder = list.parentweb.getfolder(folderurl);     return folder.exists; } 

usage:

var docsetexists = isdocumentsetexist(docs, "new docset"); 

how remove document set?

private static void deletedocumentset(documentset docset) {     docset.folder.delete(); } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -