Previous - sysFileMove Section Home - File System Next - sysFileToTrashCan


sysFileDelete ( )

Deletes an existing file

Usage:

sysFileDelete (object me, string filePath )

Parameters:

filePath (string) - a string specifying the file path to an existing file

Returns:

(integer) - The success code

Example:

-- example shows a function that takes a filePath
-- attemps to delete the file, by first removing the "read only" attribute, if it exist
On fileDelete ( strFilePath )
  xtRose = xtra("rosetta").new()
  
  If ( xtRose.sysFileExist( strFilePath ) = TRUE ) Then
    If ( xtRose.sysFileAttribute( strFilePath ) contains "r" ) Then
      -- clear the read only attribute
      xtRose.sysFileSetAttribute( strFilePath, EMPTY )
    End If
  End If
  
  -- delete the file
  return xtRose.sysFileDelete( strFilePath )
End

Notes:

This function will fail if the attribute on the file is "read only". You must first remove the read-only attribute before deleting the file. Windows may not immediately delete this file. It will wait until all instances to the file are closed before actually deleting the file.


Previous - sysFileMove Section Home - File System Next - sysFileToTrashCan