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

826
2
Jump to solution
07-30-2012 08:26 AM
SuiHuang
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!
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed 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

0 Kudos
2 Replies
KenBuja
MVP Esteemed 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
0 Kudos
SuiHuang
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
0 Kudos