Trouble deleting a database file after the database is closed

I get a 104 error code (file in use) after this code is executed. Any insights?
Should this work?

[quote=173035:@Mark Pastor]I get a 104 error code (file in use) after this code is executed. Any insights?
Should this work?[/quote]

It may take a bit more time for the database close to release the file. You may want to place the file delete into a timer so it takes place after a delay.

I will give that a shot. The other thing I just thought about is this particular file is being sync’d via GoogleDrive, so I am going to pause GoogleDrive to see if that is causing the problem. Stay tuned…

It could also be that the OS is holding on to it. On OS X it could be Spotlight for instance. Dropbox causes these issues too.

Are you saying that you are trying to delete the file from the Google Drive folder ?

Yes - the Google Drive folder on my desktop that is sync’d with Google Drive in the sky. But I paused Google Sync - that still didn’t work.

So far I tried up to 60 seconds delay after DB.close and it still didn’t work.

Next thing to try is do this with a file that is not be sync’d by Google Drive (or other syncing software).

Wow - that didn’t work either - even after waiting 60 seconds. I put the file on the Desktop (Windows 8.1) which is not being sync’d by anything, and the file still shows error code 104.

Is there any way to find what is holding the file in use? Is there anyway to test that the file is in use (with Xojo)?

FYI - I ran an independent test - new product, establish database connection, close database, delete file (without delay).
It worked as expected. So I must have something in my fairly large project that is holding the database file hostage - I need to go find that.

This test works ok here.

  Dim db As New SQLiteDatabase
  Dim dbf As FolderItem = SpecialFolder.Documents.Child("erase_this_garbage.sqlite")
  db.DatabaseFile = dbf
  if not dbf.Exists Then                // it's not there
    call db.CreateDatabaseFile            // create it
  db = nil

WHEW!!! found the culprit. I had an open sqlite prepared statement. If I assign that = Nil then close the DB, then I can delete the file.

That was a pain to find.