共用方式為


FormTemplateCollection.UploadFormTemplate Method

Uploads an InfoPath form template to a server farm.

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

Syntax

'Declaration
Public Sub UploadFormTemplate ( _
    solutionPath As String _
)
'Usage
Dim instance As FormTemplateCollection
Dim solutionPath As String

instance.UploadFormTemplate(solutionPath)
public void UploadFormTemplate(
    string solutionPath
)

Parameters

  • solutionPath
    Type: System.String
    The path and file name of the form template (.xsn) file.

Remarks

Uploading a form template does not make it available for use in SharePoint site collections. You must use the Activate method to make it available for use in site libraries. It is a good idea to use the VerifyFormTemplate method before uploading the form template if you have not previously verified that the form template can be browser-enabled.

Note

The UploadFormTemplate method does not return a FormTemplate object. Use the value of solutionPath with the ItemFromFile method of the FormTemplateCollection to set a variable equal to the uploaded form template.

Examples

In the following example, a form template located on the local file system is uploaded to the server. A console message is displayed if the process fails.

    Dim LocalFormsService As FormsService
    Dim LocalFarm As SPFarm
    Dim SolutionPath As String = "C:\FormTemplates\FormTemplate.xsn"
    Try
        LocalFarm = SPFarm.Local
        LocalFormsService = LocalFarm.Local.Services.GetValue(Of FormsService)(FormsService.ServiceName)
        LocalFormsService.FormTemplates.UploadFormTemplate(SolutionPath)
    Catch ex As Exception
        Console.WriteLine("Error: " + ex.Message)
        Console.Write("Press Enter to Continue")
        Console.ReadLine()
    End Try
    FormsService localFormsService;
    SPFarm localFarm = SPFarm.Local;
    string solutionPath = "C:\\FormTemplates\\FormTemplate.xsn";
    try
    {
        localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);
        localFormsService.FormTemplates.UploadFormTemplate(solutionPath);
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error: " + ex.Message);
        Console.Write("Press Enter to Continue");
        Console.ReadLine();
    }

See Also

Reference

FormTemplateCollection Class

FormTemplateCollection Members

Microsoft.Office.InfoPath.Server.Administration Namespace