0

Can i check if a file exists in system.DocumentsDirectory in Corona sdk?

How can i do that?

if ( myGameSettings exists ) then 

else

end

Thanks in Advance!

4

1 回答 1

3

要检查文件是否存在,您可以执行以下操作:

--> Specify the path
local path = system.pathForFile( "myGameSettings.txt", system.DocumentsDirectory )

--> This opens the specified file and returns nil if it couldn't be found
local fh = io.open( path, "r" )


if fh then

   --> File Found

else

   --> File not found

end
于 2013-05-13T21:14:31.483 回答