I’m trying to write a tiny file (5 bytes) using pathForFile to ApplicationsSupport Directory:
local path = system.pathForFile("ZC.txt", system.ApplicationSupportDirectory) local file, errorString = io.open(path,"w") if not file then print("File error attempting a write+: " .. errorString) else print("new zip code : " .. zipcode .. " : written to ZC.txt") io.write(zipcode) io.close(file) end
The end result is a zero byte file. I can watch it create the file ZC.txt (I’ve tried both “w” and “w+”… it makes no difference) in the Sandbox, but the resulting file is always empty. There are no errors.
If I manually edit the file, add a zipcode and then do an io.read, I can read it into my program just fine. I’ve tried this on the Simulator as well as an Android device, with the same results. Any ideas?