getting 101 cannot remove file.

I am trying to remove / delete a file ( MACOS )
this code produces a 101 error code - file does not exist.
the file does exist but will not remove. maybe it is permissions ?

    dfile=GetFolderItem("/Invoice/Data/customer/" + CustomerID)
  destinationFile = GetFolderItem("/Invoice/Data/arch-cust/" + CustomerID)
  dfile.CopyFileTo destinationFile
dfile.Delete()

another note
the file is not locked
i can write/update the file with no problem.

please advise.

Once you copy “dfile” to the new location, it is no longer at the path specified and, thus, dfile.Delete() produces the 101 error

No, that’s not what a copy is. That’s what a move is.

I have performed the aciton many times, the file does not remove or move.
i still get 101 error.

I have changed the routine to do a move

[code] dfile=GetFolderItem(AppPath + “/Invoice/Data/customer/” + CustomerID)
destinationFile = GetFolderItem(AppPath + “/Invoice/Data/arch-cust/” + CustomerID)

if not dfile.exists then
MsgBox "Source File Does Not Exist " + Chr(13) + _
dfile.Name
Return
end if

dfile.MoveFileTo destinationFile

If dfile.LastErrorCode > 0 then
MsgBox Str(dfile.LastErrorCode) + Chr(13) + AppPath + “/Invoice/Data/customer/” + CustomerID
end if
[/code]

Wait are you still working in the Applications directory?
Put a breakpoint on the Copy or Move steps, and see what the path is.

I am working in the App Directory i believe.

I am retrieving the Apps current path i call “AppPath”

I will try breakpoints

again , i can write to the file. i just cannot delete of move it.

Start with a breakpoint and found out what the paths for dfile and destinationFile are.

the break points did not reveal any thing new
the App path is
Applications/Apps which is correct
the dfile path is /Applications/Apps/Invoice/Data/customer/
the destination path is /Applications/Apps/Invoice/Data/arch-cust/
everything seems to be in order.

i am perplexed by this …

[quote=315900:@David Cullins]I am trying to remove / delete a file ( MACOS )
this code produces a 101 error code - file does not exist.
the file does exist but will not remove. maybe it is permissions ?

    dfile=GetFolderItem("/Invoice/Data/customer/" + CustomerID)
  destinationFile = GetFolderItem("/Invoice/Data/arch-cust/" + CustomerID)
  dfile.CopyFileTo destinationFile
dfile.Delete()

another note
the file is not locked
i can write/update the file with no problem.

please advise.[/quote]

I have the feeling of deja vu here.

Have you read what I posted here : https://forum.xojo.com/conversation/post/315897

The App directory and the root directory / require special permissions to write to it (delete is a write).

Really, really, consider using SpecialFolder.ApplicationData. Or, if you want the users to have access to the files, start in /Documents.

yes i did see that post
I have write permission so i also assumed delete permission

however you believe i should move the writes to another location
a saver location and that might solve the problem. ?

I’m honestly quite surprised that you have write ability in /Applications/ without using a declare to get elevated permissions. You should refactor your app to behave as I outlined here: https://forum.xojo.com/conversation/post/315719 (Michel was more specific a couple posts down from that one.)

It will fix your permissions issue, and will behave more like a normal Mac app.

David, it is very simple : on Mac, if you don’t use the recommended places to put your data, you are in for trouble.

If the data should be protected from prying eyes, use SpecialFolder.ApplicationData. Create your own folder in there with a name in reverse URL, such as com.greatapps.mybigapp, and do your directory structure inside.

If you don’t mind the user to potentially ruin your data, make it available in SpecialFolder.Documents.

And please, try to learn how to use FolderItems structures. This will free you from trying to do everything next to the app.

Don’t do that in /Applications, don’t do that in /Library, don’t do that in the root.

Incidentally, the same holds true under Windows 10, as well as under Linux.

Michel,

Understood.
I will move the data to SpecialFolder Documents.
and in the future i am planning on a multi User SQL.

Thank you for all that i did not know
and Thank you everyone.