I'm trying to automate one of task by creating code that will execute the
IDatabaseCompact.Compact method to a GDB file. Everything seems to work fine but there is always a .lock file generated after the Compact method is called. I am planning to do something else after the Compact process but it errors out because of the lock file.
Is there any way to close/delete the lock file?
BTW, this is how my process works:
first, I bind and initialize my system using:
_ao = New ESRI.ArcGIS.esriSystem.AoInitialize() _ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeBasic)
I then call my compact method:
Public Sub CompressFileGDB(gdbFilePath As String) Dim dbCompact As IDatabaseCompact Dim ws As IWorkspace = FileGdbWorkspaceFromPath(gdbFilePath) If (TypeOf ws Is IDatabaseCompact) Then dbCompact = CType(ws, IDatabaseCompact) If (dbCompact.CanCompact) Then Dim didFinish As Boolean = True Try dbCompact.Compact() Catch ex As Exception didFinish = False Finally dbCompact = Nothing ws = Nothing _ao.Shutdown() RaiseEvent OnProcessDone(didFinish) End Try End If End If End Sub
The compact method works, there is a significant change in the GDB file size. I also tried to set my attributes to Nothing after the process but it doesn't seem to help that much.