I’m trying to read a text file that’s in a folder named data. The data folder is in my project folder. I’m following the tutorial directions.
The code is:
function getMyDbFile(fName)
local doc_path,xText,myFile
myFile = fName
local doc_path = system.pathForFile(myFile,system.DocumentsDirectory)
print(“filename: " … tostring(doc_path))
xfile = io.open(doc_path, “r”)
if xfile then --nil if no file found
local contents = xfile:read(”*a")
io.close(xfile)
print(content)
end
end
The filename is “ContinentsDB” and it’s in folder “data”
doc_path = /Users/williamprothero/Library/Application Support/Corona Simulator/MapGame-E8B0214761B80931B11BED6D8038A65C/Documents/data/ContinentsDB.txt
The xfile variable evaluates to nil.
So, it appears that the file is not being found. Yet, it does exist. However, it doesn’t exist in the location that is found by doc_path, which is a sandbox location, I guess. Do I need to manually add the data files to the sandbox??
What’s going on?
[import]uid: 151957 topic_id: 29250 reply_id: 329250[/import]
[import]uid: 52491 topic_id: 29250 reply_id: 117703[/import]