Pre-Populating Folder(s) in Document Library with the Help of List Instance Definition


Today when I was working on a requirement, I had the need to create a customized picture library. To create this picture library the required List Schema, Definition, Instance Template, etc. were created.


One challenge I had at the end was, that this Library had to be pre-populated with a folder to store some control files.
Here is how it was resolved:

Note: I will not explain how the list definition and schema were created as there are several posts out there to help.


In the List Instance definition (manifest file), you just have to add the line shown below (Module.. Path..):

   1:  <?xml version="1.0" encoding="utf-8" ?>
   2:  <Elements xmlns="">
   4:    <ListInstance FeatureId="327B763B-A5E7-4ac2-8458-B6570D362C0B"
   5:                 Id="WattsUpImagesLibrary"
   6:                 Title="$Resources:MyResource,ListInstance_WattsUpImages_DisplayName"
   7:                 Description="$Resources:MyResource,ListInstance_WattsUpImages_Description"
   8:                 Url="WattsUpImagesLibrary"
   9:                 TemplateType="3111" 
  10:                 OnQuickLaunch="FALSE" />
  11:    <!-- Adding a folder to the list instance-->
  12:    <Module Path="ControlFiles" Url="WattsUpImagesLibrary/ControlFiles" />
  13:  </Elements>

Please take a special note of the URL attribute, the value “WattsUpImagesLibrary” is the one used above as URL of the instance.

The output as a result of this:


IMPORTANT: To be able to create folder in Document Library, your list need to have the content reference of “0x0120” OR a custom one derived from it in the format of 0x0120 + 00 + <Guid>