This is what I use to check it any file exists.
[code]
myDocumentFileAndPath = system.pathForFile(“FileName.db”, system.DocumentsDirectory) --Write Access folder
myResourceFileAndPath = system.pathForFile(“FileName.db”, system.ResourceDirectory) --Protected Folder - Read only access
– CHECK TO SEE IF THE DB EXISTS, IF NOT THEN CREATE IT –
if doesDBFileExists(myDocumentFileAndPath) == false then
–open / create a new empty db file
end
if doesDBFileExists(myResourceFileAndPath) == false then
–open / create a new empty db file
end
–
– Check if DB File exists
– Returns true if it exists
function doesDBFileExists(sFileAndPath)
local bResults = false
if _G.debug then
print(" doesDBFileExists ->> the file path ->> " … sFileAndPath )
end
– io.open opens a file at filePath. returns nil if no file found
local file = io.open( sFileAndPath, “r” )
if file then – YES FILE OPENed -->
io.close( file )
bResults = true
else – FILE - NOT - OPENed -->
bResults = false
end
if _G.debug then
if bResults then
print (“doesDBFileExists ->> true”)
else
print (“doesDBFileExists ->> false”)
end
end
return bResults
end
[/code] [import]uid: 11860 topic_id: 17917 reply_id: 68498[/import]