This documentation is archived and is not being maintained.

SPContentType.ResourceFolder Property

Windows SharePoint Services 3

Gets the relative folder path for the content type's resource folder.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Public ReadOnly Property ResourceFolder As SPFolder
Dim instance As SPContentType
Dim value As SPFolder

value = instance.ResourceFolder

Property Value

Type: Microsoft.SharePoint.SPFolder
An SPFolder object that represents the resource folder.

The resource folder is the storage location for any file, such as a document template, that is used by the content type.

The following example is a console application that displays information about the resource folder for every content type on every list in a Web site. As it iterates through the lists and their content types, the application collects the total size of files in each resource folder and prints an accumulated total to the console at the end of the run.

Imports System
Imports Microsoft.SharePoint

Module Test
   Sub Main()
      Using site As SPSite = New SPSite("http://localhost")
         Using web As SPWeb = site.OpenWeb()
            Dim resourceSize As Long = 0
            For Each list As SPList In web.Lists
               For Each ct As SPContentType In list.ContentTypes
                  resourceSize += ResourceFolderInfo(list, ct)
               Next ct
            Next list
            Console.WriteLine(vbCrLf + "Total size of files in all resource folders = {0} bytes", resourceSize.ToString())
         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
   End Sub

   Private Function ResourceFolderInfo(ByRef list As SPList, ByRef ct As SPContentType) As Long
      If list Is Nothing OrElse ct Is Nothing Then
         Throw New ArgumentException()
      End If

      Dim fldr As SPFolder = ct.ResourceFolder
      Dim total As Long = 0

      Console.WriteLine(vbCrLf + "Content type name: {0}", ct.Name)
      Console.WriteLine("Relative path to resource folder: {0}", fldr.ServerRelativeUrl)

      Console.Write("Files in folder:")
      For Each file As SPFile In fldr.Files
         Console.WriteLine(" {0}", file.Name)
         total += file.Length
      Next file

      Return total
   End Function

End Module