Friday, January 14, 2011

Create/Get Documents from Document set programmatically in Sharepoint 2010

here i have one "Test Docs" library and it has some items which was created by using document set contenttype. when i click on on "Documentset item" it shows welcome page. i am trying to get documents which r in welcome page by using below code. SPFolder folder = SPContext.Current.ListItem.Folder; DocumentSet dset = DocumentSet.GetDocumentSet(folder); SPListItem listitem = dset.Item; foreach (SPFile item in listitem.Folder.Files) { } Create DOcument set programmatically in sharepoint 2010 SPList WorkingDocslist = web.Lists["TestDocs"]; SPFolder folderToInsertIn = WorkingDocslist.RootFolder; //Get the content type ID for the specified document set content type. SPContentTypeId dsCtId = new SPContentTypeId(); Hashtable properties = new Hashtable(); properties.Add("projectid", projectID); properties.Add("TaskID", taskID); //Create the new Document Set object. string strDocSetName = string.Empty; dsCtId = WorkingDocslist.ContentTypes["Project Negotiations Package"].Id; DocumentSet.Create(folderToInsertIn, strDocSetName , dsCtId, properties, true);

No comments:

Post a Comment