1

VB.NET against ArcGIS 10.1 I have a function which searches a geodb for a feature class name. If found I would like to display where it was found. Currently I only return the FeatureClass object like so:

Dim fcTest As IFeatureClass = FindFeatureClassByName(pWorkspace, fcName)

It works great but now I would like to display the full catalog path of the feature class object. Is that possible?

I've been looking for hours but can't seem to do it. The Feature Class could exist in a Feature Dataset. So the feature class could be in locations like

    E:\Batch\Delivered.gdb\Bridges
    D:\Data\Final\Infrastructure.gdb\EastValley\powerlines
    C:/projects/RedRiverBasin/data.mdb/streams
    C:/projects/Airports/USA.mdb/West/lax

Does that info get included in the FeatureClass object or do I have to tweak my function?

I tried:

Dim pDataset As IDataset = CType(fcTest, IDataset)

But pDataset.Name is only the name of the feature class and not the full catalog path and name including any Feature Dataset if that's where its located.

1

Found a solution and it was fairly straightforward:

''' <summary>
''' this routine will return the full catalog path and name of a feature class.
''' </summary>
''' <param name="pFeatClass">the feature class object</param>
''' <returns>a string representing the catalog path of the feature class</returns>
''' <remarks>https://geonet.esri.com/thread/4280</remarks>
Public Function GetCatalogPath(ByVal pFeatClass As IFeatureClass) As String
    Try
        'check for valid object
        If pFeatClass Is Nothing Then Return Nothing

        'cast to dataset and get workspace
        Dim pDataset As IDataset = CType(pFeatClass, IDataset)
        Dim pWksp As IWorkspace = pDataset.Workspace

        'the full path may be in a fetaure dataset so check it
        Dim pFeatDs As IFeatureDataset = pFeatClass.FeatureDataset
        If pFeatDs Is Nothing Then
            Return System.IO.Path.Combine(pWksp.PathName, pDataset.Name)
        Else
            Return System.IO.Path.Combine(pWksp.PathName, pFeatDs.Name, pDataset.Name)
        End If
    Catch ex As Exception
        Return Nothing
    End Try
End Function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.