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 。。。
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'?
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
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
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
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.
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!).
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.
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.