如何检查lua(Corona SDK)中system.DocumentsDirectory中是否存在文件?

时间:2013-05-13 19:38:25

标签: android lua corona

我可以检查Corona sdk中system.DocumentsDirectory中是否存在文件吗?

我该怎么做?

if ( myGameSettings exists ) then 

else

end

提前致谢!

1 个答案:

答案 0 :(得分: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