Here is some code from my app:
[code] f = GetFolderItem (filename, FolderItem.PathTypeNative)
if (f.Exists=false) then
// Do something else, like return, exit, or continue
end if
f.delete ()
if (f.LastErrorCode>0) then
msg = "unable to delete file: " + filename
writeLog (msg)
end if
[/code]
Generally, the file is deleted, but sometimes when it deletes it, the LastErrorCode
is 101 which means “File not found”. Anything I need to know here? The file does exist and should be owned by the user - it will have been written recently by the app itself, as follows:
[code]binstr = BinaryStream.Create (atFile, false)
if (binstr=Nil) then // Couldn’t open the new file
msg = “error, could not create new file”
me.task.UIwriter (1, msg)
return
end if
result = dbreadBlob (me.dbhimg, absid, image, imagelen) // Here, I read a blob from an SQLite database
if (result<>app.READ_OK) then
msg = “error, could not read file from database”
me.task.UIwriter (1, msg)
return
end if
binstr.write (image) // Write image out
binstr.flush ()
binstr.close () // Wrote the file out OK, can close it now
[/code]
The deletion may only be requested a few minutes after the file is created. Should I be doing something like binstr = NIL
? This is on OS X and the Finder shows the file as in its folder, so I assume it has been written out - but who knows.