Getting filepath from resource
See original GitHub issueI need to get absolute filepath of specified file which is later used by another assembly to read that file. I know how to get file using resm or avares but I was not able to find solution for this and doesn’t matter for me if I set build action to AvaloniaResource or Embedded resource or whatever.
Using Assembly.GetExecutingAssembly().GetManifestResourceNames() I only get string !Avalonia. Does anyone has an idea how to solve this issue? Thanks in advance
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
How to get absolute path to file in /resources folder of your ...
Create the classLoader instance of the class you need, then you can access the files or resources easily. now you access path using...
Read more >Java - Read a file from resources folder
In Java, we can use getResourceAsStream or getResource to read a file or multiple files from a resources folder or root of the...
Read more >Get the Path of the /src/test/resources Directory in JUnit
In this tutorial, we'll learn how to read the path of the /src/test/resources directory. 2. Maven Dependencies. First, we'll need to add JUnit...
Read more >Read a File from Resources Directory
File file = ResourceUtils.getFile("classpath:demo.txt") //File is found System.
Read more >Read a File from Resources Folder in Java
This tutorial covers How to read a file from Classpath or Resources Folder in Java with practical examples using File IO, NIO and...
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 Free
Top 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

I just solved this by using
System.AppDomain.CurrentDomain.BaseDirectory+Assets\Sounds\my_sound.mp3and changedmy_sound.mp3build action tononeand copy to output directory toCopy if newer… It works flaweless on Windows and Linux (Raspberry Pi)… so simple and it has nothing to do with avalonia… but the solution as @jp2masa suggested should work tooGetAssetsis for retrieving a list of assets in a “folder”, e.g.GetAssets("avares://MyAssembly/Assets/Sounds", null)would return a list with a single URI:avares://MyAssembly/Assets/Sounds/my_sound.mp3.