Android Question Getting number of files of manually created folders

Sub7

Active Member
Licensed User
Longtime User
Hello, i need to get the number of file in some folders manually moved to file.dirassets
in future releases is i may need to add some more files, i'd like to avoid to correct all the code by updating the default values.



B4X:
Dim fileCount As List
fileCount = File.ListFiles(File.DirAssets) 'OK

fileCount = File.ListFiles(File.DirAssets&"/foldername") 'NOT OK
'error java.io.IOException: AssetsDir/foldername is not a folder.

Log(fileCount.Size)


B4X:
'Bad code
Dim numfiles as int = 50 'I know the total number of files in file.dirassets/foldername
if counter <= 50 Then....

'I prefer
if counter <= filecount.size Then....


any walktrought?
 
Top