Can't Access Raw Asset Path
See original GitHub issueSay I have an asset called livefree.ogg
that is located in Raw/Songs
Application
|-Resources
|-Raw
|-Songs
|-livefree.ogg -> Build Action: Maui Asset
If I need to say, loop over all the files in Raw/Songs, how do I do so? Using FileSystem.OpenAppPackageFileAsync
doesn’t get me access to the path of the item, just a stream. Which in my case, I need a path and not a stream. Is this possible with MAUI?
None of the following return any files:
Directory.GetFiles("Songs");
Directory.GetFiles("/Songs");
Directory.GetFiles("Resources/Songs");
Directory.GetFiles("/Resources/Songs");
Directory.GetFiles("Raw/Songs");
Directory.GetFiles("/Raw/Songs");
Directory.GetFiles("Resources/Raw/Songs");
Directory.GetFiles("/Resources/Raw/Songs");
Directory.GetFiles(Path.Combine(FileSystem.AppDataDirectory, "Songs"));
Directory.GetFiles(Path.Combine(FileSystem.AppDataDirectory, "Raw", "Songs"));
Directory.GetFiles(Path.Combine(FileSystem.AppDataDirectory, "Resource", "Raw", "Songs"));
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top Results From Across the Web
How to get access to raw resources that I put in res folder?
For raw files, you should consider creating a raw folder inside res directory and then call getResources().
Read more >Resource Raw Folder in Android Studio
In Android one can store the raw asset file like JSON, Text, mp3, HTML, ... Step 1: To create the Resource Raw folder...
Read more >Assets or Resource Raw folder of Android? | by Elye
Compile-time checking: res/raw is possible. assets folder. Here, the way you read it into InputStream is assets.open("filename").
Read more >Assets Folder in Android Studio
If one wants to access data untouched, Assets are one way to do it. ... In Android one can store the raw asset...
Read more >File system helpers - .NET MAUI
NET MAUI projects will process any file in the Resources\Raw folder as a MauiAsset. The FileSystem.OpenPackageFileAsync method can't get the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That particular function is related to C# reflection and not specific to Android. It can work if you set the build action to ‘Embedded Resource’ instead of a ‘MauiAsset’.
Although a workaround, it would be nice to have direct access to MauiAssets. I’m going to guess there is some lower level OS limitations with direct access and maybe that is why it isn’t available.
@xtuzy, so you’re saying the only possible way would be to copy all resources to the apps local data folder, then accessing them that way? I personally don’t like this as it would double the size of the resources.