题
我正在创建列表定义。当我们为列表定义创建ElementS.xml时,我要创建一些文件夹。
提前感谢
解决方案
在component.xml中添加以下代码以在列表中创建文件夹。
<Data>
<Rows>
<Row>
<Field Name="ContentTypeId">0x0120004F994A3C0FF76546A528DA0D4B515898</Field>
<Field Name="FileLeafRef">MyTestFolder</Field>
<Field Name="Title">MyTestFolder</Field>
<Field Name="FSObjType">1</Field>
</Row>
</Rows>
</Data>
.
有关更多信息,请参阅以下文章
http://msdn.microsoft。COM / EN-IN / LIBLUCE / MS478860(v= Office.14).aspx
http://johnlearnt.blogspot.in/in/2012/09 / provision-folder-inside-document-library.html
此外,您可以在创建列表时从事件接收器进行:
为库定义(dev Center)创建一个事件接收器(列表)。 添加代码以创建文件夹结构。
溅列表= web.lists.tregetList(“listtitle”);
spfoldercollection foldercoll= list.rootfolder.subfolders;
spfolder newfolder= foldercoll.add(folderull);