Android Question File.Exists Issue

David Hawkins

Active Member
Licensed User
Longtime User
Hi

I appear to be getting a strange result with file.exists. If the file exists then all is OK but if the file does not exist it is created by the file.exists function. My question is, should that happen.

I have checked and double checked to make sure that the case sensitivity is correct but the issue is still there.

Regards

David
 

David Hawkins

Active Member
Licensed User
Longtime User
Hi guys thank you for your fast response code is below

B4X:
    If File.Exists(File.DirRootExternal & "/RWW/", DownloadedDBname) = True Then
        File.Copy(File.DirRootExternal & "/RWW/", DownloadedDBname, File.DirRootExternal & "/RWW/", Main.DatabaseName)
        File.Copy(File.DirRootExternal & "/RWW/", DownloadedDBname.ToUpperCase, File.DirRootExternal & "/RWW/", "BACKUP.DB")
        File.Delete(File.DirRootExternal & "/RWW/", DownloadedDBname)
    End If

Regards

David
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Knock, knock ? Could it be because the path is artificially created and not created using File.Combine ?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
B4X:
    If File.Exists(File.DirRootExternal & "/RWW/", DownloadedDBname) = True Then
        File.Copy(File.DirRootExternal & "/RWW/", DownloadedDBname, File.DirRootExternal & "/RWW/", Main.DatabaseName)
        File.Copy(File.DirRootExternal & "/RWW/", DownloadedDBname.ToUpperCase, File.DirRootExternal & "/RWW/", "BACKUP.DB")
        File.Delete(File.DirRootExternal & "/RWW/", DownloadedDBname)
    End If



This code definitely does not create the file.

It is created elsewhere, such as NJDude wrote, or the file was previously created and not deleted. When you uninstall an app, files in the DirRootExternal are not automatically deleted.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…