Type Function Library os.* Return value String and Boolean Revision 2017.3060 Keywords remove, delete, file See also system.pathForFile() os.rename() io.*
Deletes a file or directory and returns two possible values:
result
— true
if the file was successfully removed, otherwise false
.reason
— nil
if remove was successful, otherwise a string describing the reason for failure.You can only remove files in the DocumentsDirectory, ApplicationSupportDirectory and TemporaryDirectory. Files in the ResourceDirectory are
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