Use files etc in Maui

Lloyd Sheen 1,391 Reputation points

I have some 50 image files which my app should be able to read as the ImageSource for a particular item in the app. There is a name property which corresponds to the filename of the .png file.

I have now spent 2 days trying all sorts of things trying the accomplish the above.

The latest is I create a folder under Images with the image files.

Now for testing I have the following code to see what is in the file system of Android.

    var path = AppDomain.CurrentDomain.BaseDirectory;  

    List<string> dirFilesFromPath= Directory.EnumerateFiles(path).ToList();  
    List<string> dirDictoriesFromPath =Directory.EnumerateDirectories(path).ToList();  

    foreach(string dirFile in dirDictoriesFromPath)  
        List<string> dirDictories = Directory.EnumerateDirectories(dirFile).ToList();  
        List<string> dirFiles=Directory.EnumerateFiles(dirFile).ToList();  

        foreach(string drF in dirDictories )  
            List<string> dirDictories2 = Directory.EnumerateDirectories(drF).ToList();  
            List<string> dirFiles2 = Directory.EnumerateFiles(drF).ToList();  

No matter what I have done the folder the files do not enumerate.

I have read about 100 posts about Maui and the file system but nothing in them helps.

The MS documentation is nowhere as to telling how to do what I want to do.

I want to be able to show an image from this app which has been put as (I really don't know and have tried everything Embedded Resource is last try) and have the file name as a property in the Item and should be able to read the image and present an ImageSource.

This is so easy in Xamarin and I keep reading how Maui is going to make things easier. Not accomplished up to now.

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,981 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Lloyd Sheen 1,391 Reputation points

    Well I managed to find a way (not a great way) to load from a file.

    Now Xamarin file names all sorts of letters , spaces etc and uppercase.

    Now Maui does not allow this and I see that this is because of the Android file naming conventions.

    Some one should tell Xamarin.

    0 comments No comments