FormTemplateCollection Class
Represents all Administrator-approved form templates on the server farm.
Inheritance Hierarchy
System.Object
Microsoft.SharePoint.Administration.SPPersistedObjectCollection<FormTemplate>
Microsoft.SharePoint.Administration.SPPersistedChildCollection<FormTemplate>
Microsoft.Office.InfoPath.Server.Administration.FormTemplateCollection
Namespace: Microsoft.Office.InfoPath.Server.Administration
Assembly: Microsoft.Office.InfoPath.Server (in Microsoft.Office.InfoPath.Server.dll)
Syntax
'Declaration
<GuidAttribute("543DD7B9-6E48-438d-86D8-100000000000")> _
Public NotInheritable Class FormTemplateCollection _
Inherits SPPersistedChildCollection(Of FormTemplate) _
Implements IBackupRestoreConfiguration, IBackupRestore
'Usage
Dim instance As FormTemplateCollection
[GuidAttribute("543DD7B9-6E48-438d-86D8-100000000000")]
public sealed class FormTemplateCollection : SPPersistedChildCollection<FormTemplate>,
IBackupRestoreConfiguration, IBackupRestore
Remarks
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.
Examples
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.
Note
Browse for the [Microsoft.Office.InfoPath.Server] assembly at <drive>:\Program Files\Microsoft Office Servers\14.0\Bin.
The following import statements are required for the
Microsoft.Office.Server, Microsoft.Office.InfoPath.Server.Administration, and Microsoft.SharePoint.Administration namespaces:
Dim LocalFormsService As FormsService
Dim LocalFarm As SPFarm
Dim FormTemps As Integer
Try
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")
Console.ReadLine()
Catch ex As Exception
Console.WriteLine("Error: " + ex.Message)
Console.Write("Press Enter to Continue")
Console.ReadLine()
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;
try
{
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");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
Console.Write("Press Enter to Continue");
Console.ReadLine();
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.