cannot delete file maybe due to permissions.

FOR MAC
sometimes i cannot delete files, right now there are multi copies of my software being ran on different computers all accessing a network drive, updating files at different times. i am finding sometimes i cannot delete a file, but it seems to write ok, what could be the issue ? below is a sample of the “delete” Code.

please advise …

[code]Dim sourceFile, destinationFile as FolderItem
Dim CustomerID As String
Dim AppFolder As FolderItem = GetFolderItem("")

if CusIdList.ListIndex < 0 then
MsgBox “No CustomerID Selected !”
return
end if

CustomerID = CusIdList.List(CusIdList.ListIndex)

If CusOutstandingBalance > 0 Then
if RemoveOverRide.State = Checkbox.CheckedStates.Unchecked Then
MsgBox “Warning: Archieve Customer has an outStanding Balance !”
//return
End if
End if

if MsgBox ("Warning about to Archive current record: " + CustomerID, 1) = 2 then
return
end if

sourceFile = GetDataFolder.Child(SoftName).Child(“Data”).Child(“customer”).Child(CustomerID)
destinationFile = GetDataFolder.Child(SoftName).Child(“Data”).Child(“arch-cust”)
sourceFile.Permissions = 777
destinationFile.Child(CustomerID).Permissions = 777

if PerminateDeleteChk.State = Checkbox.CheckedStates.Checked then
if sourceFile <> Nil or sourceFile.Exists then
sourceFile.Delete
end if

if destinationFile.Child(CustomerID) <> Nil and destinationFile.Child(CustomerID).Exists Then
destinationFile.Child(CustomerID).Delete
end if
MsgBox CustomerID + “customer perminately remoted”
Return
else
if destinationFile.Child(CustomerID) <> Nil and destinationFile.Child(CustomerID).Exists Then
destinationFile.Child(CustomerID).Delete
End if

sourceFile.MoveFileTo(destinationFile.Child(CustomerID))
ClearCustButton.Push
end if

If sourceFile.LastErrorCode > 0 then
MsgBox "Error-Code: " + Str(sourceFile.LastErrorCode) + Chr(13) + GetAppPath + “/Invoice/Data/customer/” + CustomerID
return
end if

CusIdList.RemoveRow(CusIdList.ListIndex)

CusIDLabel.Text = Str(CusIdList.ListCount) + " Customers Found"
Status2.text = CustomerID + " Archived - Record Processed"
[/code]

Is there an error? Usually the file is busy - or at least seems to be.

As Beatrix says it is most likely that the file is open somewhere or there might be a slight network glitch at the moment you are trying to delete the file or any number of other possibilities. Now given that your code suggests you are doing something important you should be very concerned! This is not a reliable approach and no matter how much effort you put in will never become one. Think about a database solution.

Yes - there is an error when i try to update or save this file - “exception 5000”
when signed in as superuser and viewing via a terminal a “ls -l” command produces “_unknown:_unknown” owner
SU also cannot remove this file. after exiting SU the owner returns to “myusername” : “staff”
also most files have this rxw rxw rxw @ permissions
the file that cannot be deleted has rx rx rx @ , apparently even SU cannot change it.

and one more thing, even when view the file(s) in question in finder i cannot delete it. it says “The operation can’t be completed because you don’t have permission to access some of the items.”

at this time i am looking into a database, this is a longer term solution,

Select the file in the finder, right-click and select Get Info. At the bottom it should show permissions.

greg

yes i just updated my last post with the owner and permissions.
the file that cannot be deleted has rx rx rx @ , apparently even SU cannot change it.

when signed in as SU the owners show as “_unknown”

Two things;

  1. Try using “Permissions Reset” on that file http://www.ohanaware.com/permissionsreset/.
  2. I wrote an article for a recent xDev magazine (15.6) about creating a one-for-all file delete routine. http://xdevmag.com