How to delete offline geodatabase replica file?

4995
6
03-30-2015 03:03 AM
JuhoVainio
Occasional Contributor

If I unregister the replica with GeodatabaseSyncTask, then how do I delete the actual geodatabase file? The problem is that if I open the geodatabase, the file stays open until I open another geodatabase (even closing the application doesn't remove the lock).

There is no Close method for closing the geodatabase explicitly.

Tags (1)
0 Kudos
6 Replies
by Anonymous User
Not applicable

You won't find a delete method in the Geodatabase class itself, but instead will want to use File.Delete from System.IO and do it manually.  This mirrors how the file is created when you download the geodatabase from the server.

0 Kudos
JuhoVainio
Occasional Contributor

Yes, but the problem is that the once I open the geodatabase file, it stays open until the application is closed, so it cannot be deleted be any means ("The file is being used by another process").

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Unfortunately this is a known issue which is under investigation.

Cheers

Mike

HeikkiNiemisara
New Contributor

Mike,

Could you provide us the bug number for this. I can't find relevant bugs in the system. with the keywords within this discussion.

Best regards,

Heikki

0 Kudos
by Anonymous User
Not applicable

Maybe as a workaround you could restart the application and delete the file at startup before you would reopen the application.  Probably not the greatest way to handle it, but it might could get you down the road.  Here is a link on how to restart a .NET application (Application.Restart Method (System.Windows.Forms) ).

0 Kudos
JuhoVainio
Occasional Contributor

Yes, that's a possibility, but in my case the deletion of the geodatabase depends on the data within the database, so I need to open the db to check if the file is eligible for deletion. Of course I could to this in two phases, first phase being the check to save the filenames pending for deletion and so on...

Thanks anyway for the response.

0 Kudos