[英]How to check if a file exists in the system.DocumentsDirectory in lua (Corona SDK)?
我可以檢查Corona SDK中system.DocumentsDirectory中是否存在文件嗎?
我怎樣才能做到這一點?
if ( myGameSettings exists ) then
else
end
提前致謝!
要檢查文件是否存在,您可以執行以下操作:
--> 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.