This has been covered a few times it seems, but I have been unable to get it working unfortunately. I found a few threads and come up with this function
--Checks If File Exists
fileCnt = 0
function fileExists(fileName)
local filePath = system.pathForFile( fileName, '' )
local exists = false
local fileHandle = io.open( filePath, "r" )
if (fileHandle) then
exists = true
io.close(fileHandle)
end
fileCnt = fileCnt + 1
display.newText( " " .. filePath, 10, fileCnt \* 30, native.systemFont, 10)
return(exists)
end
Now this works when running in the emulator and displays the full path of my files (so c:\users\stevil\documents\corona\project\assets\img.png) returns true and all runs fine. Put it on my andriod device and it returns false even if the file does exist and the the path isn’t generated (so just shows assets\img.png)
I tried turning it to just return true (as I know it will be true at the moment) and it all worked fine, it loaded the images I was checking fine. The code is something along the lines of:-
fileName = 'assets/img.png'
if fileExists(fileName) == true then
display.newImageRect(fileName, 10,10,100,100)
end
That’s just a rough example, it’s used in similar ways in multiple spots.
Am I doing something wrong here? I’ve looked at a few examples and everything appears to be right. I’m wonder if it’s something andriod related I’m missing?
Any help anyone can off me would be greatly appreciated =)
[import]uid: 133056 topic_id: 26339 reply_id: 326339[/import]