Android Question B4A Files Manager is uncapitalizing files

fern

Member
Licensed User
It seems the IDE Files Manager is automatically uncapitalizing files in the Files directory and that "File.Exists" is case sensitive - thus causing a problem if string logic relies on filename case and uppercase is used. Is this a correct observation?

For example when using:
If File.Exists(DirAssets, FileName) then 。。。
 

fern

Member
Licensed User
Just to make sure we're on the same page (since my explanation not the most precise), are you saying that your code snippet would return True even though the filename is actually 'somefile.jpg'?

Thanks for your response.
 
Upvote 0

fern

Member
Licensed User
Here is a more clear example as to what I am seeing.

I have the following 4 files in the Files directory:
'john_file.txt'
'ralph_file.txt'
'michael_file.txt'
'mary_file.txt'

In the following code example, the first two test_names are lower case and return "Found" (True), the second two names are uppercase and return "Not Found" (False).

All the files are synced in the IDE Files Manager.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim i As Int
    Dim txt,filename As String
    Dim test_names(4) As String


    test_names(0) = "john"
    test_names(1) = "ralph"
    test_names(2) = "Michael"
    test_names(3) = "Mary"

    For i = 0 To 3                        
        filename = test_names(i) & "_file.txt"

        txt = Find_File(filename)
    Next           

End Sub

Sub Find_File(filename As String) As String
  If File.Exists(File.DirAssets, filename) = False Then Return "Not Found"
      Return "Found"
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
In the following code example, the first two test_names are lower case and return "Found" (True), the second two names are uppercase and return "Not Found" (False).

I ran your code with a very slight modification by adding another file to the mix and all files were found. I use B4A 6.50. That is precisely the expected behavior:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Dim i As Int
    Dim txt,filename As String
    Dim test_names(5) As String

    test_names(0) = "john"
    test_names(1) = "ralph"
    test_names(2) = "Michael"
    test_names(3) = "Mary"
    test_names(4) = "FeRn"

    For i = 0 To 4                        
        filename = test_names(i) & "_file.txt"
        txt = Find_File(filename)
        Log(txt)
    Next          
End Sub

Sub Find_File(filename As String) As String
    If File.Exists(File.DirAssets, filename) = False Then Return "Not Found" & "  " & filename
    Return "Found" & "  " & filename
End Sub
 
Upvote 0

fern

Member
Licensed User
Thank you for testing that. I'm running 6.5 also. Windows 7 64 bit.

I don't know what environmental factor would lead to my results, but that's what I'm getting. It's being very literal with the caps.
 
Upvote 0

fern

Member
Licensed User
I just tried your project with the same results. It's not finding the Michael, Mary, or FeRn files.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I ran it on 3 devices: OS 4.2.2, OS 5.1 and OS 6.0.1. All found them:
Found john_file.txt
Found ralph_file.txt
Found Michael_file.txt
Found Mary_file.txt
Found FeRn_file.txt
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Here's a screenshot of my log
All I can tell you is to try it on a different device if you have one more robust. I even tried mine with Legacy and Rapid debuggers. Both work well. If not, let us wait for @Erel to address it or others to test also.
 
Upvote 0

fern

Member
Licensed User
It is a fresh install of Windows that I just did last week - completely updated with the latest patches. It's running very smoothly otherwise.

This isn't an emergency issue for me - I have plenty of other things to work on. If I get time later, I'll install B4A on a Windows 10 machine and try it there. But this may be a good thing to nail down anyway, especially since this will be my main development machine (I hope!).

Thanks.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
It is a fresh install of Windows that I just did last wee
I was not referring to your PC. I do not think the problem is with your PC. I was referring to your tablet or phone. You never mentioned the make and the operating system version.
 
Upvote 0

fern

Member
Licensed User
OK - I got you now.

I was using Genymotion "Custom Tablet 6.0.0 API 23" but just tried on AVD "Nexus 6 Android 7.1.1 API Level 25" with the same results. I'm running Java 8 update 121 64-bit.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…