AnsweredAssumed Answered

Is there an efficient way in ArcObjects to delete many tables at once?

Question asked by Hornbydd on Feb 14, 2016
Latest reply on Aug 16, 2017 by Grieck

All,

 

I have a tool that can populate a file geodatabase with hundreds to several thousand tables (some tables can be very small others very large). My current VB code searches the file geodatabase and deletes tables using the following logic:

 

Dim pEnumDataset As IEnumDataset
pEnumDataset = pWorkspace.Datasets(esriDatasetType.esriDTTable)
pDataSet = pEnumDataset.Next
Do While Not pDataSet Is Nothing
     If pDataSet.CanDelete = True Then
         If Right(pDataSet.BrowseName, 12) = "Upstream_IDs" Then
             pDataSet.Delete()
           End If
      Else
           ' Error
            Return Nothing
    End If
    pDataSet = pEnumDataset.Next
Loop

 

When there are thousands of tables ending with the suffix "upstream_IDs", this process can be quite slow. I don't want to delete the entire geodatabase as there may be other tables that need to remain.

 

I was wondering if any ArcObjects Guru out there know of a way to batch delete tables? I was thinking if there was some way of providing a list or an enumerator to some interface that can delete tables efficiently?

Outcomes