Xojo won't delete a file [2019r1.1)

I have this routine in an app

Private Sub XCODE_Open(filename As String, XCODE_level as Integer=1)
  Dim f As FolderItem
  f            = XCODE_Filename(filename,XCODE_level)
  If f.Exists Then f.Delete
  XCODE_file   = TextOutputStream.Create(f)
  XCODE_Indent = 0
End Sub

It is called dozens of times, but every once in a while if FAILS to delete an existing file and then fails with NOE on the CREATE line

When I checked the drive, the FILE was there (just an older version). I manually delete it and the code continues as it should

This file, is created by this App and used by this app… so it is not like something else is snagging on to it…

changed above code to

Dim f As FolderItem
f            = XCODE_Filename(filename,XCODE_level)
If f.Exists Then f.Delete
Try
  XCODE_file   = TextOutputStream.Create(f)
Catch e As IOException
  MsgBox "Unable to create or write to file = "+f.Displayname
End Try
XCODE_Indent = 0

now it doesn’t NOE on me, but it still fails on occasion

actually its entirely possible the the meta data importers have done exactly this

in the catch portion you could run “lsof” on that specific file and that command cant tell you exactly what is holding on to the file

something like

   lsof <path to file here>

should show what processes are accessing that file

No idea if remotely applicable to you or if it suggests anything to you, but I have seen this on Azure virtual file systems where there’s a delay in the deletion being completed, such that the file still exists when you try to open it to overwrite; deletions take time and are non-blocking. I’ve also seen it on the local filesystem when running a machine that’s being throttled because its CPU quota is used up.

Because we have a lot of stuff on this crappy cloud file system, I have a deletion method that checks every 200 ms that the file is actually gone, until it is. Same with renames, copies, moves, directory creation / rename /move. Weird thing about such file systems is they are pretty responsive in all respects (reading / writing / opening / closing) except actually creating or deleting files or (especially) folders.

Thanks… I think I determined it was XCODE at “fault”

The Xojo app creates files for use by Xcode… and for some reason Xcode would hold a lock on one or two of the files (Xojo creates about 50 files that Xcode uses all at the same time)

So I modified the Xojo code, to warn that Xcode is running before it attempts to recreate things

1 Like