Type Function Library os.* Return value String and Boolean Revision 2018.3320 Keywords remove, delete, file See also system.pathForFile() os.rename() io.*
Deletes a file or directory and returns two possible values:
trueif the file was successfully removed, otherwise
nilif remove was successful, otherwise a string describing the reason for failure.
os.remove( file )
String. String specifying the name of the file or directory to remove.
local destDir = system.DocumentsDirectory -- Location where the file is stored local result, reason = os.remove( system.pathForFile( "apple.txt", destDir ) ) if result then print( "File removed" ) else print( "File does not exist", reason ) --> File does not exist apple.txt: No such file or directory end