Test if IName Object is a Shapefile

708
2
Jump to solution
04-15-2013 01:25 AM
MickeyO_Neil
New Contributor III
Hello,

ArcCatalog saves Objects as an IName Object in the Clipboard.

I want to test an Object if it is a Shapefile, a Table from a Geodatabase or a dBase-Table.
Dim pObject As Object pObject = pName.Open 'PName is the IName-Object from Clipboard  If TypeOf pObject Is IFeatureClass Then ... ElseIf TypeOf pObject Is ITable Then ... End If


It works, but it is not good enough. It could be any type of Table or Feature-Class.
Any idea how to test if the Object is exactly a Shapefile or dBase?

Thanks
0 Kudos
1 Solution

Accepted Solutions
ThavitinaiduGulivindala
Occasional Contributor
Cast IName to IDatasetName and then check the IDatasetName.WorkspaceName is shapefile directory or not, using IWorspaceName2.Type or IWorspaceName2.WorkspacefactoryProgID property

View solution in original post

0 Kudos
2 Replies
ThavitinaiduGulivindala
Occasional Contributor
Cast IName to IDatasetName and then check the IDatasetName.WorkspaceName is shapefile directory or not, using IWorspaceName2.Type or IWorspaceName2.WorkspacefactoryProgID property
0 Kudos
MickeyO_Neil
New Contributor III
Thank You!

Here is the new code:
My top one is wrong, because you can't open every type of an IName Object.

If TypeOf pName Is IDatasetName Then

Dim pDatasetName As IDatasetName
pDatasetName = pName

Dim pWorkspaceName As IWorkspaceName2
pWorkspaceName = pDatasetName.WorkspaceName

     If pDatasetName.Type = esriDatasetType.esriDTFeatureClass Then

      'Shapefile?
           If pWorkspaceName.WorkspaceFactoryProgID.Contains("esriDataSourcesFile.ShapefileWorkspaceFactory") Then
           '...
           End If
     End If
End If
0 Kudos