ArcObjects Geodatabase Access – Opening Files Using Browse Dialog Command (VB.NET/C#)

arcgis-10.0arcobjectscspatial-database

I am currently using the following method with ArcGIS 10 to open raster files from a form:

Public Function BrowseRaster(ByVal sTitle As String, ByRef sFolder As String, ByRef sName As String) As Boolean

 Dim pGxDialog As IGxDialog = New GxDialog
    Dim pRasterFilter As IGxObjectFilter = New GxFilterRasterDatasets()

    Dim pFilterCol As IGxObjectFilterCollection
    Dim pEnumGx As IEnumGxObject
    Dim pGxObject As IGxObject

    sFolder = ""
    sName = ""

    pFilterCol = pGxDialog
    pFilterCol.AddFilter(pRasterFilter, True)
    'pGxDialog.StartingLocation = ""
    pGxDialog.RememberLocation = True
    pGxDialog.AllowMultiSelect = False
    pGxDialog.Title = sTitle


        If pGxDialog.DoModalOpen(0, pEnumGx) Then
            pGxObject = pEnumGx.Next
            Dim sFile As New FileInfo(pGxObject.FullName)
            'sName = pGxObject.BaseName
            sName = pGxObject.Name
            sFolder = sFile.Directory.FullName
            Return True
        End If

End Function

How can I modify this function to also open files from inside of a file geodatabase?

Best Answer

Look at the very bottom of the list of objects that implement IGxObjectFilter

Create instances of RasterFormatFGDBFilter, RasterFormatPGDBFilter and RasterFormatSDEFilter and add them to your IGxObjectFilterCollection. This will enable Rasters inside GDBs. If you want to allow other FeatureClasses to be opened look at the list and also add those filters.