Questions tagged [embedded-resource]

Resources (such as images and help files) that are embedded into the binary of the application itself and typically not available as files.

Embedded resources are resources such as images and help files that are embedded into the binary of the application itself. Such resources would normally not be available as files. There are methods available for loading resources from URLs or input streams in most languages.

Java

This is how an URL might be formed, that points to an embedded resource within a Jar on the run-time class-path of a Java based app.

URL url = this.getClass().getResource("/path/to/the.resource");

This is how an input stream reading from the embedded resource can be formed:

InputStream is = this.getClass().getResourceAsStream("/path/to/the.resource");

Several detailed tutorials and examples are cited here.

1918 questions
32
votes
4 answers

Resource from assembly as a stream

I have an image in a C# WPF app whose build action is set to 'Resource'. It's just a file in the source directory, it hasn't been added to the app's resource collection through the drag/drop properties dialog. I'm trying to write it as a stream, but…
Echilon
  • 10,064
  • 33
  • 131
  • 217
30
votes
5 answers

How to Read an embedded resource as array of bytes without writing it to disk?

In my application I compile another program from source.cs file using CodeDom.Compiler and I embed some resources ( exe and dll files ) at compile time using : // .... rest of code if (provider.Supports(GeneratorSupport.Resources)) { …
Rafik Bari
  • 4,867
  • 18
  • 73
  • 123
28
votes
4 answers

MEF and Razor Views inside Class Library

I have a composite ASP .NET MVC 3 Razor application using MEF. Everything goes fine if I am to deploy plugins as DLL files and views (CSHTML) under the regular Views folder from the application. But this is not very clean and it won't be a real…
27
votes
4 answers

Is there any standard way of embedding resources into Linux executable image?

It is quite easy to embed binary resources into PE images (EXE, DLL) via Windows API (refer to http://msdn.microsoft.com/en-us/library/ms648008(v=VS.85).aspx). Is there any similar standard API in Linux? or maybe some kind of de-facto approach to…
Andrey
  • 4,216
  • 1
  • 23
  • 31
25
votes
5 answers

How to use shared resource file between projects in one solution?

I have a problem with resource files. I have a solution with two projects. The first project contains ImageResource.resx file with the images that I use. Every Form in this project can access this file from the designer. But I can see in the…
Yuriy
  • 2,670
  • 6
  • 33
  • 48
23
votes
2 answers

Can I change the marker in a Google Maps embedded map (iframe)?

I know I can do it with the Google Maps API, but do you know if there is a way to change the marker in an embedded Google Map? I want to replace the default "A" button for a "B" button or the marker with just a dot in the middle.
ana
  • 1,565
  • 4
  • 17
  • 22
22
votes
2 answers

How do I add a TXT file as resource to my EXE file?

I have a TXT file containing about 10,000 lines of text. I want to display these lines in a TMemo. But I don't want to distribute that TXT file my program. How do I integrate it into my EXE file as a resource WITHIUT using stringtable {} because…
Gabriel
  • 20,797
  • 27
  • 159
  • 293
22
votes
1 answer

Are embedded resources in a .NET Assembly loaded from disk or from memory at runtime?

When I use GetManifestResourceStream to retrieve an embedded resource from a .NET assembly, what kind of I/O is involved? I see two possibilities: The entire assembly was already put into memory when .NET loaded it, so GetManifestResourceStream is…
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
22
votes
4 answers

How to embed multilanguage *.resx (or *.resources) files in single EXE?

There are plenty of tutorials how to create multilanguage RESX files and how to create satellite assemblies with AL.exe, but I haven't found working example how to embed RESX/Resources/satellite-DLL files in single EXE file and distribute whole…
tomash
  • 12,742
  • 15
  • 64
  • 81
22
votes
8 answers

How to read a resource file within a Portable Class Library?

I have a Portable Library which I am using for a Windows Phone application. In that same Portable Library, I have a couple of content files (Build Action = Content). I created a class DataReader in the Portable Library which is supposed to return me…
Martin
  • 39,309
  • 62
  • 192
  • 278
19
votes
2 answers

Where do resource files go in a Gradle project that builds a Java 9 module?

As of IDEA 2018.2.1, the IDE starts error-highlighting packages "not in the module graph" from dependencies that have been modularized. I added a module-info.java file to my project and added the requisite requires statements, but I'm now having…
David Moles
  • 48,006
  • 27
  • 136
  • 235
19
votes
4 answers

Cant load embedded resource with GetManifestResourceStream()

I am embedding a binary file with the /linkres: compiler argument, but when i try to load it with: System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetExecutingAssembly(); string[] names = myAssembly.GetManifestResourceNames(); //…
clamp
  • 33,000
  • 75
  • 203
  • 299
19
votes
3 answers

RazorEngine string layouts and sections?

I use razor engine like this: public class EmailService : IService { private readonly ITemplateService templateService; public EmailService(ITemplateService templateService) { if (templateService == null) { …
bevacqua
  • 47,502
  • 56
  • 171
  • 285
18
votes
3 answers

How can I force Proguard to keep my .xml resource file?

I am succesfully using proguard for my Android apps. However, with one app I am having trouble. This app uses a java library that has a .xml file that is stored in the package. InputStream istream =…
Peterdk
  • 15,625
  • 20
  • 101
  • 140
18
votes
2 answers

Conditionally embedding a resource in Visual Studio (C#)

Is there a way to conditionally embed resources into a .NET project? I.e. if I have defined INCLUDETHIS then I want a certain large file embedded into the dll, otherwise I do not want it embedded. I know I can make two projects to do this, but I'm…
jjxtra
  • 20,415
  • 16
  • 100
  • 140