江湖路
专注AJAX和Moss
 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();

                    }
                   
                }
            }

 

posted on 2013-02-27 13:58  wengnet  阅读(441)  评论(0编辑  收藏  举报