Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
FormTemplateCollection Class

FormTemplateCollection Class

Represents all Administrator-approved form templates on the server farm.

Namespace:  Microsoft.Office.InfoPath.Server.Administration
Assembly:  Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)

public sealed class FormTemplateCollection : SPPersistedChildCollection<FormTemplate>

User form templates and those deployed as content types to site collections are not enumerated in the FormTemplateCollection collection. Administrator-approved form templates are deployed as content types, and are enumerated in the collection.

The following two examples write the count of Administrator-approved form templates to the console. References are required in the Visual Studio project to the [Microsoft.Office.Server], [Microsoft.Office.InfoPath.Server], and [Microsoft.SharePoint] assemblies.


Browse for the [Microsoft.Office.InfoPath.Server] assembly at <drive>:\Program Files\Microsoft Office Servers\12.0\Bin.

Visual Basic

The following import statements are required for the

[Microsoft.Office.Server], [Microsoft.Office.InfoPath.Server.Administration], and [Microsoft.SharePoint.Administration] namespaces:

Visual Basic

    Dim LocalFormsService As FormsService
    Dim LocalFarm As SPFarm
    Dim FormTemps As Integer

        LocalFarm = SPFarm.Local
        LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
        FormTemps = LocalFormsService.FormTemplates.Count()
        Console.WriteLine("Number of form templates: " & FormTemps.ToString())
        Console.Write("Press Enter to Continue")
    Catch ex As Exception
        Console.WriteLine("Error: " + ex.Message)
        Console.Write("Press Enter to Continue")
    End Try


The following using statements are required for the

[Microsoft.Office.Server], [Microsoft.Office.InfoPath.Server.Administration], and [Microsoft.SharePoint.Administration] namespaces.


    FormsService localFormsService;
    SPFarm localFarm = SPFarm.Local;
    Int16 formTemps;

        localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);
        formTemps = (Int16)localFormsService.FormTemplates.Count;
        Console.WriteLine("Number of form templates: " + formTemps.ToString());
        Console.Write("Press Enter to Continue");
    catch (Exception ex)
        Console.WriteLine("Error: " + ex.Message);
        Console.Write("Press Enter to Continue");

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

© 2015 Microsoft