using (SPSite site = new SPSite("http://sharepoint2010")) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists.TryGetList("Docs"); SPContentType ct = web.ContentTypes[new SPContentTypeId("0x0120D520")]; var hashTable = new Hashtable(); hashTable.Add("DocumentSetDescription", "test"); DocumentSet documentSet = DocumentSet.Create(list.RootFolder, "test", list.ContentTypes.BestMatch(ct.Id), hashTable,true); SPFolder folder = documentSet.Folder; using (FileStream strm = new FileInfo(@"C:\test\test.txt").Open(FileMode.Open)) { byte[] data = new byte[strm.Length]; strm.Read(data, 0, (int)strm.Length); folder.Files.Add("test.txt", data); folder.Update(); } } }