Gestire i file udl

Ecco un paio di funzioni che ho scritto per creare e aprire un file udl tramite la DataLink Dialog utilizzando il namespace System.Diagnostics evitando così il reference ad AdoDb:

 

Public Shared Function CreateUDLFile(ByVal udlFilePath As String) As Boolean
            Dim file As New System.IO.FileInfo(udlFilePath)

            ‘Creazione file
            file.Create().Close()

            ‘Apertura file
           
OpenUDLFile(udlFilePath)

            ‘In caso di annullamento il file non viene generato e lo si elimina
           
If file.Length = 0 Then
               
file.Delete()
               
Return False
           
End If

            Return True
End Function

 

Public Shared Sub OpenUDLFile(ByVal udlFilePath As String)
            Dim process As System.Diagnostics.Process
            process = System.Diagnostics.Process.Start(udlFilePath)

            process.WaitForExit()
           
            process.Close()
            process.Dispose()
            process =
Nothing
End Sub