Export (0) Print
Expand All

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)

public void UploadFormTemplate(
	string solutionPath
)

Parameters

solutionPath
Type: System.String

The path and file name of the form template (.xsn) file.

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.

NoteNote

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.

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.

    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();
    }
Show:
© 2015 Microsoft