{"id":26821167,"url":"https://github.com/andrei15193/embeddedresourcebrowser","last_synced_at":"2026-05-19T04:36:47.212Z","repository":{"id":157928463,"uuid":"307065704","full_name":"Andrei15193/EmbeddedResourceBrowser","owner":"Andrei15193","description":"A small utility library for browsing the embedded resources of an assembly.","archived":false,"fork":false,"pushed_at":"2022-02-09T19:41:39.000Z","size":198,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-06-19T05:05:03.210Z","etag":null,"topics":["assembly","browser","embedded","resource","utility"],"latest_commit_sha":null,"homepage":"https://Andrei15193.github.io/EmbeddedResourceBrowser","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Andrei15193.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-10-25T09:36:36.000Z","updated_at":"2022-01-29T13:32:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"4089d5aa-b24e-48df-a095-cee205cd9a78","html_url":"https://github.com/Andrei15193/EmbeddedResourceBrowser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Andrei15193/EmbeddedResourceBrowser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrei15193%2FEmbeddedResourceBrowser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrei15193%2FEmbeddedResourceBrowser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrei15193%2FEmbeddedResourceBrowser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrei15193%2FEmbeddedResourceBrowser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Andrei15193","download_url":"https://codeload.github.com/Andrei15193/EmbeddedResourceBrowser/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrei15193%2FEmbeddedResourceBrowser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260690830,"owners_count":23047099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","browser","embedded","resource","utility"],"created_at":"2025-03-30T07:18:33.350Z","updated_at":"2026-05-19T04:36:47.174Z","avatar_url":"https://github.com/Andrei15193.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"### EmbeddedResourceBrowser\n\nA small utility library for browsing the embedded resources of an assembly.\n\nFor project documentation go to https://Andrei15193.github.io/EmbeddedResourceBrowser\n\nTo see the latest development (`dev` branch) go to https://andrei15193.github.io/EmbeddedResourceBrowser/dev\n\n----\n\nThe library is rather small and provides a directory-like structure for browsing embedded resources. You can load resources in multiple ways depending on how you wish to use them in your application. Before detailing each approach it is important to note that embedded resources in .NET assemblies use the dot (`.`) character as a separator for directories. This can be a bit confusing because we can add the dot (`.`) in the name of a directory or a file and there will be absolutely no difference of having a directory structure or using the dot (`.`) in the name. For instance, the following two resources are identical and the compiler will issue an error indicating this.\n\n```\nAssembly/\n    Directory/\n        embedded file.txt\n    Directory.embedded file.txt\n\nBoth resources are embedded (by default) with the following logical name:\nAssembly.Directory.embedded file.txt\n```\n\nIf you wish, you can provide a custom logical name for your embedded resource, keep in mind that you need to specify this manually. For instance, you can use the forwards slash (`/`) as a separator by specifying the logical name of an embedded resource. For more information refer to: [Common MSBuild project items - EmbeddedResource](https://docs.microsoft.com/visualstudio/msbuild/common-msbuild-project-items?view=vs-2019#embeddedresource).\n\n```xml\n\u003cEmbeddedResource Include=\"Directory.embedded file.txt\" LogicalName=\"AssemblyName/Directory/embedded file.txt\"/\u003e\n```\n\nThe library detects the path separator from the embedded file name. It expects that embedded resource names start with the assembly name followed by the path separator. By default, this would mean the dot character (`.`), however resources can be embedded under a different name using the LogicalName attribute. When using this option ensure that the assembly name is added at the beginning of the name and add the path separator after it.\n\nSee [EmbeddedDirectory](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.html) for more information.\n\n### Working With One Assembly\n\nGenerally, you may be working with just one assembly from where you load embedded resources. In this case initialize a new [EmbeddedDirectory](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.html) by passing the assembly object containing the embedded resources to the constructor. This will load all resources in a directory tree where the root is the directory having the same name as the assembly name and all resources can be browsed, and loaded, from there. The following method will concatenate the contents of each embedded file at the top level of the assembly.\n\n```c#\nstring ConcatResources()\n{\n    var embeddedDirectory = new EmbeddedDirectory(typeof(ACustomType).Assembly);\n\n    var resultBuilder = new StringBuilder();\n    foreach (var file in embeddedDirectory.Files)\n        using (var streamReader = new StreamReader(file.OpenRead()))\n            resultBuilder.AppendLine(streamReader.ReadToEnd());\n    return resultBuilder.ToString();\n}\n```\n\n### Working With Multiple Assemblies\n\nSometimes the project can be rather complex and embedded resources are placed in multiple assemblies. In this case an [EmbeddedDirectory](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.html) can be created by providing all assemblies as constructor arguments which in turn will create a root directory containing a subdirectory for each provided assembly that have the same structure as in the working with one assembly scenario. The following method will concatenate the contents of each embedded file at the top level of each assembly, but also append the assembly name from where files are being read.\n\n```c#\nstring ConcatResources()\n{\n    var embeddedDirectory = new EmbeddedDirectory(typeof(ACustomTypeFromAssembly1).Assembly, typeof(ACustomTypeFromAssembly2).Assembly);\n\n    var resultBuilder = new StringBuilder();\n    foreach (var assemblyDirectory in embeddedDirectory.Subdirectories)\n    {\n        resultBuilder.AppendLine(assemblyDirectory.Name);\n        resultBuilder.AppendLine(new string('-', 80));\n        foreach (var file in embeddedDirectory.Files)\n            using (var streamReader = new StreamReader(file.OpenRead()))\n                resultBuilder.AppendLine(streamReader.ReadToEnd());\n    }\n    return resultBuilder.ToString();\n}\n```\n\nThis works well with pattern matching. To find different file or directory structures you can use the[GetAllFiles](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.GetAllFiles.html)() and [GetAllSubdirectories](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.GetAllSubdirectories.html)() methods to get all files/directories and use [LINQ](https://docs.microsoft.com/dotnet/csharp/programming-guide/concepts/linq) to match different structures.\n\n### Working With Multiple Assemblies (Merge Method)\n\nA different scenario when working with multiple assemblies is when we want to have resources that are placed in multiple assemblies, but instead of loading each of them we want to have a precedence between them, so even though we have multiple assemblies with embedded resources, we want to provide an implicit set that can be overriden in other assemblies. For instance, I would like to provide a default set of embedded resources that can be overridden by users of my library.\n\nGiven the following structure of embedded directories, I can override any of these resources (or add) from a different assembly using the [Merge](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.Merge.html)([IEnumerable](https://docs.microsoft.com/dotnet/api/System.Collections.Generic.IEnumerable-1?view=netstandard-1.6)\u003c[Assembly](https://docs.microsoft.com/dotnet/api/System.Reflection.Assembly?view=netstandard-1.6)\u003e) method.\n\n```\nMyAssembly/\n    Directory1/\n        File 1.txt\n        File 2.txt\n    Directory2/\n        File 1.txt\n```\n\nThis would be the default set of resources, now, when loading mapping resources from multiple assemblies using the [Merge](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.Merge.html)([IEnumerable](https://docs.microsoft.com/dotnet/api/System.Collections.Generic.IEnumerable-1?view=netstandard-1.6)\u003c[Assembly](https://docs.microsoft.com/dotnet/api/System.Reflection.Assembly?view=netstandard-1.6)\u003e) method some of these resources can be overridden and a few more resources can be added to the set. Having a second assembly with the following structure will create an [EmbeddedDirectory](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.html) with resources from both assemblies.\n\n```\nOtherAssembly/\n    Directory1/\n        File 2.txt\n        File 3.txt\n    Directory3/\n        File 1.txt\n```\n\nThe resulting structure will be the following, note that the root directory, or any directory, does not have the assembly name anymore since directories can contain resources from mixed assemblies.\n\n```\n/\n    Directory1/\n        File 1.txt (from MyAssembly)\n        File 2.txt (from OtherAssembly, matching resource names)\n        File 3.txt (from OtherAssembly)\n    Directory2/\n        File 1.txt (from MyAssembly)\n    Directory3/\n        File 1.txt (from OtherAssembly)\n```\n\nTo create an [EmbeddedDirectory](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.html) using the [Merge](https://andrei15193.github.io/EmbeddedResourceBrowser/EmbeddedResourceBrowser.EmbeddedDirectory.Merge.html)([IEnumerable](https://docs.microsoft.com/dotnet/api/System.Collections.Generic.IEnumerable-1?view=netstandard-1.6)\u003c[Assembly](https://docs.microsoft.com/dotnet/api/System.Reflection.Assembly?view=netstandard-1.6)\u003e) method simply call the static method instead of calling the constructor.\n\n```c#\nstring ConcatResources()\n{\n    var embeddedDirectory = EmbeddedDirectory.Merge(typeof(ACustomTypeFromAssembly1).Assembly, typeof(ACustomTypeFromAssembly2).Assembly);\n\n    var resultBuilder = new StringBuilder();\n    foreach (var file in embeddedDirectory.Files)\n        using (var streamReader = new StreamReader(file.OpenRead()))\n            resultBuilder.AppendLine(streamReader.ReadToEnd());\n    return resultBuilder.ToString();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrei15193%2Fembeddedresourcebrowser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrei15193%2Fembeddedresourcebrowser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrei15193%2Fembeddedresourcebrowser/lists"}