ec2
February 9, 2011, 10:39am
1
Hi,
I store persistent game data in a file but in some cases I would like to delete the file completely. I’ve tried:
file = io.open( filePath, "w+" )
io.close( file )
and this clears the contents, creating an empty file, but the file is still there.
Is there a way to completely delete the file?
Thanks
EC [import]uid: 29384 topic_id: 6307 reply_id: 306307[/import]
luna
February 9, 2011, 11:35am
2
Try this:
[lua]local results, reason = os.remove( “apple.txt” )
if results then
print( “file removed” )
else
print( “file does not exist”, reason )
end
–> file does not exist apple.txt: No such file or directory[/lua]
More info at:
http://developer.anscamobile.com/reference/index/osremove [import]uid: 8045 topic_id: 6307 reply_id: 21779[/import]
ec2
February 9, 2011, 11:41am
3
Tried it, and it does exactly what I wanted! Thanks for the quick response luna. [import]uid: 29384 topic_id: 6307 reply_id: 21781[/import]
luna
February 9, 2011, 11:53am
4
Good to hear it’s working. I was trying to do the same thing a few days ago. [import]uid: 8045 topic_id: 6307 reply_id: 21787[/import]