Share via


DataConnectionFileCollection.Enumerate Method

Enumerates the data connection files in the collection based on the mode.

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

Syntax

'Declaration
Public Function Enumerate ( _
    mode As String _
) As String()
'Usage
Dim instance As DataConnectionFileCollection
Dim mode As String
Dim returnValue As String()

returnValue = instance.Enumerate(mode)
public string[] Enumerate(
    string mode
)

Parameters

  • mode
    Type: System.String
    The default value for Mode is "a" or "all" to enumerate all UDC files in the collection, or "u" to enumerate only those UDC files that do not have dependent form templates.

Return Value

Type: []
A one dimensional array of strings containing the file names of the enumerated data connection files.

Examples

In the following collection, a one dimensional array is used to capture the file name of all data connection files on the server by using the Enumerate method.

Visual Basic

    Dim LocalFormsService As FormsService
    Dim LocalFarm As SPFarm
    Dim i As Integer = 0
    Try
        LocalFarm = SPFarm.Local
        LocalFormsService = LocalFarm.Services.GetValue(Of FormsService)(FormsService.ServiceName)
        Dim strEnum() As String = UdcCollection.Enumerate("all")
        For i = 0 To strEnum.Length
            Console.WriteLine("Data Connection File " + i.ToString() + ": " + strEnum(i))
        Next
        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

C#

    FormsService localFormsService;
    SPFarm localFarm = SPFarm.Local;
    try
    {
        localFormsService = localFarm.Services.GetValue<FormsService>(FormsService.ServiceName);
        DataConnectionFileCollection udcCollection = localFormsService.DataConnectionFiles;
        string[] enumUdc = udcCollection.Enumerate("All");
        for (int i = 0;i < enumUdc.Length;i++)
        {
            Console.WriteLine("Data Connection File " + i.ToString() + ": " + enumUdc[i]);
        }
        Console.Write("Press Enter to Continue");
        Console.ReadLine();
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error: " + ex.Message);
        Console.Write("Press Enter to Continue");
        Console.ReadLine();
    }

See Also

Reference

DataConnectionFileCollection Class

DataConnectionFileCollection Members

Microsoft.Office.InfoPath.Server.Administration Namespace