question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting filepath from resource

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
B8ightYcommented, Feb 9, 2021

I just solved this by using System.AppDomain.CurrentDomain.BaseDirectory + Assets\Sounds\my_sound.mp3 and changed my_sound.mp3 build action to none and copy to output directory to Copy 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 too

2reactions
jp2masacommented, Feb 8, 2021

GetAssets is 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found