I am creating list definitions.Now what I want to create some folder when We create Elements.xml for list definition.
Thanks in advance
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityAdd the following code in Elements.xml to create folder in list.
<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>
Refer to following articles for more information
http://msdn.microsoft.com/en-IN/library/ms478860(v=office.14).aspx
http://johnlearnt.blogspot.in/2012/09/provision-folder-inside-document-library.html
Also, you can do it from an event receiver when the list is created:
Create an event receiver (ListAdded) for the library definition (Dev Center). Add code to create the folder structure.
SPList list = web.Lists.TryGetList("ListTitle");
SPFolderCollection folderColl = list.RootFolder.SubFolders;
SPFolder newFolder = folderColl.Add(FolderUrl);