embedded-resource

GetManifestResourceStream returns NULL

送分小仙女□ 提交于 2019-11-26 19:26:53
问题 This is a C# .NET 4.0 application: I'm embedding a text file as a resource and then trying to display it in a dialog box: var assembly = Assembly.GetExecutingAssembly(); var resourceName = "MyProj.Help.txt"; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { using (StreamReader reader = new StreamReader(stream)) { string result = reader.ReadToEnd(); System.Windows.Forms.MessageBox.Show(result, "MyProj", MessageBoxButtons.OK); } } The solution is MyProjSolution and the

JavaScript: Changing src-attribute of a embed-tag

99封情书 提交于 2019-11-26 19:04:54
I have the following scenario. I show the user some audio files from the server. The user clicks on one, then onFileSelected is eventually executed with both the selected folder and file. What the function does is change the source from the embedded object. So in a way, it is a preview of the selected file before accepting it and save the user's choice. A visual aid . HTML <embed src="/resources/audio/_webbook_0001/embed_test.mp3" type="audio/mpeg" id="audio_file"> JavaScript function onFileSelected(file, directory) { jQuery('embed#audio_file').attr('src', '/resources/audio/'+directory+'/'

What is the correct path to display an ImageIcon png file for Windows 7?

試著忘記壹切 提交于 2019-11-26 18:37:04
问题 I wanted to test having a program with a simple png image on it. I wrote a short program that does this, but I can't seem to get the path right. I have checked, checked again, rechecked, and quadruple checked my path name as to not get it right, but this image will not display, no matter what I do. I used a short class wrote by Oracle in the ImageIcon documentation (the creaetImageIcon() ) to accomplish this, but it doesn't seem to help. I'll post the entire program below, as it is very short

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

被刻印的时光 ゝ 提交于 2019-11-26 18:11:36
问题 This question already has answers here : Embedding resources in executable using GCC (4 answers) Closed 5 years ago . 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 resource embedding? The goal is to embed some static binary and/or textual data into executable, e.g. pictures, HTMLs, etc.. so that

Google Apps Script: How to set “Use column A as labels” in chart embedded in spreadsheet?

喜你入骨 提交于 2019-11-26 17:57:35
I am using Google Apps Script and EmbeddedChartBuilder to embed line charts within my Google Spreadsheet. When you create these charts by hand, you have the (non-default) option to "Use column A as labels" (where "A" is the first column in the data range). I cannot find a way to do the same from a script. From the Google Visualization Line Chart documentation, it appears that the default is to treat the first column as having the "domain" role; but EmbeddedChartBuilder seems to override this and give all columns the "data" role. Since I don't have an explicit DataTable, I have no way to set

How can I extract a file from an embedded resource and save it to disk?

梦想与她 提交于 2019-11-26 17:36:40
I'm trying to compile the code below using CSharpCodeProvider. The file is successfully compiled, but when I click on the generated EXE file, I get an error (Windows is searching for a solution to this problem) and nothing happens. When I compile the code below using CSharpCodeProvider, I've added the MySql.Data.dll as an embedded resource file using this line of code: if (provider.Supports(GeneratorSupport.Resources)) cp.EmbeddedResources.Add("MySql.Data.dll"); The file is successfully embedded (because I noticed the file size increased). In the code below, I try to extract the embedded DLL

Getting images from a .jar file

青春壹個敷衍的年華 提交于 2019-11-26 17:20:53
问题 I need to get res folder to compile when I export a executable jar file in eclipse also when I use the getClass().getResource() method it doesn't work. Current reading image code public Image loadImage(String fileName) { return new ImageIcon(fileName).getImage(); } Code that doesn't work public Image loadImage(String fileName) { return new ImageIcon(getClass().getResource(fileName).getImage(); } 回答1: I have now fixed the problem - this is the code that works public BufferedImage loadImage

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

一曲冷凌霜 提交于 2019-11-26 16:44:14
问题 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 trouble accessing resource files in my src/main/resources directory. (For a complete example, see this GitHub project.) When I used ./gradlew run or ./gradlew installDist + the resulting wrapper script, I was able to read resource files, but when I

How do I add an image to a JButton

冷暖自知 提交于 2019-11-26 15:11:56
I am trying to add an image to a JButton and I'm not sure what I'm missing. When I run the following code the button looks exactly the same as if I had created it without any image attribute. Water.bmp is in the root of my project folder. ImageIcon water = new ImageIcon("water.bmp"); JButton button = new JButton(water); frame.add(button); Rogach I think that your problem is in the location of the image. You shall place it in your source, and then use it like this: JButton button = new JButton(); try { Image img = ImageIO.read(getClass().getResource("resources/water.bmp")); button.setIcon(new

Accessing JAR resources

僤鯓⒐⒋嵵緔 提交于 2019-11-26 12:46:40
问题 I have a jar file with resources (mainly configuration for caches, logging, etc) that I want to distribute. I\'m having a problem with the relative paths for those resources, so I did what I\'ve found in another stackoverflow question, which said that this was a valid way: ClassInTheSamePackageOfTheResource.class.getResourceAsStream(\'resource.xml\'); Sadly this does not work. Any ideas? Thanks! PS: Obviously I cannot use absolute paths, and I\'d like to avoid environment variables if