In-memory workspace: how to check the existance of feature layer and tables?

555
2
Jump to solution
07-30-2012 08:26 AM
Highlighted
Occasional Contributor II
Hi Everybody:

    I am developing an ArcMap 10 (service pack 4) customize tool. I want to use in-memory workspace to hold some temporary data, but found that the in-memory workspace I created does not support IWorkspace2 interface such that I cannot use IWorkspace2.NameExists to check whether table or feature class is already created. Following is the screenshot of the Watch window showing this fact:
[ATTACH=CONFIG]16477[/ATTACH]

   Is there any alternative to check the existance of objects in the in-memory workspace?
   Thank you!
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Honored Contributor
How about looping through the datasets in the workspace and seeing if the name ("YourFClass") is in there? I've tested this with an In-memory workspace.

Dim pEnumDS As ESRI.ArcGIS.Geodatabase.IEnumDataset Dim pDataset As ESRI.ArcGIS.Geodatabase.IDataset  pEnumDS = pWorkspace.Datasets(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTAny)  Do Until pDataset Is Nothing     If pDataset.Name = "YourFClass" then         System.Windows.Forms.MessageBox.Show("Exists")         Exit Do     pDataset = pEnumDS.Next Loop

View solution in original post

Reply
0 Kudos
2 Replies
Highlighted
MVP Honored Contributor
How about looping through the datasets in the workspace and seeing if the name ("YourFClass") is in there? I've tested this with an In-memory workspace.

Dim pEnumDS As ESRI.ArcGIS.Geodatabase.IEnumDataset Dim pDataset As ESRI.ArcGIS.Geodatabase.IDataset  pEnumDS = pWorkspace.Datasets(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTAny)  Do Until pDataset Is Nothing     If pDataset.Name = "YourFClass" then         System.Windows.Forms.MessageBox.Show("Exists")         Exit Do     pDataset = pEnumDS.Next Loop

View solution in original post

Reply
0 Kudos
Highlighted
Occasional Contributor II
Thank you Ken! Seems this is the only available way.

How about looping through the datasets in the workspace and seeing if the name ("YourFClass") is in there? I've tested this with an In-memory workspace.


Dim pEnumDS As ESRI.ArcGIS.Geodatabase.IEnumDataset
Dim pDataset As ESRI.ArcGIS.Geodatabase.IDataset

pEnumDS = pWorkspace.Datasets(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTAny)

Do Until pDataset Is Nothing
    If pDataset.Name = "YourFClass" then
        System.Windows.Forms.MessageBox.Show("Exists")
        Exit Do
    pDataset = pEnumDS.Next
Loop
Reply
0 Kudos