Dotnet Core: List names of all embedded resource files

2020.12.15 | 137 words |


I’m building a dotnet core web service and trying to add some embedded resources. However every time I try to access them by file name, I can’t seem to find the embedded resources. How can I get all the names of the files that are embedded in my project?


We can do this by using Reflection on an Assembly and getting the manifest resources.

Here’s some example code:

using System;
using System.Reflection;

namespace MyApp {
    public class Program {
        public static void main(string[] args) {
            var resourceNames = Assembly.GetExecutingAssembly()
            foreach(string name in resourceNames) {
                Console.WriteLine($"Resource: {name}");

This will grab the executing Assembly (the current ‘program’) and get all the embedded resource files via the GetManifestResourceNames call. It then loops through each of these names and prints them to the console.


About the Ham

Hi I'm Hamilton - I built this! If you want more content like this subscribe to my email list, connect with me around the web, or take a look at some of my other projects.

More Projects

comments powered by Disqus