Hi,
I am trying to load a file, it doesn’t find the file, I don’t know what I did wrong?
I added a Documents folder and put the filename.txt inside (and also in the same folder as the lua files), and it says :
File error: /Users/lincoln/Library/Application Support/Corona Simulator/testua-5AB745870794E893FF8732F713128C7D/Documents/map1.txt: No such file or directory
I am on Mac, so I also tried .rtf file, but same error.
If I use system.ResourceDirectory instead of DocumentsDirectory, it triggers an error at “io.open” : “Bad argument #1 to ‘open’ (string expected, got nil)”
local function loadS()
local path = system.pathForFile( "map1.txt", system.DocumentsDirectory )
local file, errorString = io.open( path, "r" )
if not file then
print( "File error: " .. errorString )
else
local contents = file:read( "*a" )
tt = tonumber( contents )
print("after read file : "..tt)
io.close( file )
end
file = nil
end