embedded-resource

Creating Images from an Embedded Resource

安稳与你 提交于 2019-12-05 09:39:12
This has been driving me crazy for the past 2 days, and anything close that I find just does not seem to work in my situation, perhaps someone can point out what I'm doing wrong. I have a WPF project to which I've include a fairly large number of images(80ish). I've added them to the project into a folder called "Images". They are currently set to be embedded resources(though I've tried regular resources as well) but nothing seems to work. I am attempting to create and load an ArrayList of type Image using these files as the source, but I'm failing pretty bad. private void addPicture(string

Why is the generated class for a resource file in a file with a different name?

给你一囗甜甜゛ 提交于 2019-12-05 05:59:42
I have a resource file strings.resx, and the generated resource class is in strings1.designer.cs. Why is this the case? The problem specifically is the "1". The class name inside that file is "strings", as it should be. Note that I did try deleting the designer.cs and regenerating it by saving the resx file, but that didn't change anything. I just ran into this problem and found the issue inside the .csproj file. It appears that Visual Studio saves the last filename it used and attempts to generate using that filename again. So if for some reason the Strings.designer.cs is ever generated as

Why are resx cultures not found in unit tests?

隐身守侯 提交于 2019-12-05 05:51:52
I have embedded string resources in my .NET 4.0 project: Strings.resx and Strings.de.resx. In production code the correct localised strings are retrieved, dependent on the value of Strings.Culture: Strings.Culture = new Culture("de"); string deString = Strings.Welcome; // 'Willkommen' Strings.Culture = new Culture("en"); string enString = Strings.Welcome; // 'Welcome' But in my unit test code (using MSTest) the strings from 'Strings.de.resx' are never returned - I only ever get the strings from Strings.resx, no matter what the values of Strings.Culture or Threads.CurrentThread.CultureUICulture

Visual Studio 2008: How do I include project output as an embedded resource in another project?

柔情痞子 提交于 2019-12-05 04:19:46
I have two projects in one Visual Studio 2008 solution. I'd like to use the primary output from one of the projects as an embedded resource in the other, but for the life of me I can't find any way to accomplish this. If I simply add the output file as a resource, then it doesn't seem to change when its source project is rebuilt. I even have the project dependencies/build order set up properly and this does not seem to help. Anyone have any hints for me? Thanks! When you add an existing file to a project, Visual Studio copies the file into the project's directory. Any subsequent changes to the

Visual Studio Installer Project: Installer and Application Icons

走远了吗. 提交于 2019-12-05 03:41:44
I've got an icon for one of my applications, which I've embedded in a resource file and is used as the main icon for the application. So far so good. However, I want to use the same icon for the installer project, and for the shortcut that the installer places in the Start Menu. I can set the icon for the installer package itself, but only if I add the icon as an .ico file in the main application folder. The whole point of embedded the icon in a resource file is so that I don't have an ICO file floating around in Program Files. I can't access the resource file from the main project in the

How do I check if an embedded resource exists or not?

亡梦爱人 提交于 2019-12-05 02:22:08
In Delphi, I'm building an HTTP Application, or a Web Server rather. It's essentially an entire website built into a single EXE file. The files I'm embedding include HTML, JS, CSS, SWF, PNG, XML, etc. The resource names are the same as the original filename, with the . replaced with an _ . In the end, there will be somewhere around 40-60 files embedded inside the EXE. The problem is I don't want to write code wrapping each and every individual file. Right now, I am declaring a constant for each resource, and using that constant when acquiring the resource using TResourceStream . The HTTP

How to read text from a text file in the XAP?

限于喜欢 提交于 2019-12-05 01:03:01
问题 I'm working on an out-of-browser Silverlight program, and I have successfully gotten it to open local files by means of an OpenFileDialog. However, now I need it to open a file from within its own XAP (no browsing necessary, the file to open is hard-coded). I am trying to use this code, but it's not working: using (StreamReader reader = new StreamReader("Default.txt")) { TextBox1.Text = reader.ReadToEnd(); } This code throws a SecurityException that says "File operation not permitted. Access

Java getClass().getResource(“file”) leads to NullPointerException

十年热恋 提交于 2019-12-04 23:12:25
I am following the zetcode Snake java games tutorial and always get this error: ImageIcon iid = new ImageIcon(this.getClass().getResource("ball.png")); ball = iid.getImage(); Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(Unknown Source) at snake2.Board.<init>(Board.java:52) at snake2.Snake.<init>(Snake.java:10) at snake2.Snake.main(Snake.java:22) I actually just copied and pasted the code to see how it works. They are in the right packages too; but when I try to run it, I always end up with this error. Bozho The image should be in the same package

How to access a resource / configuration / text file in an external Jar from Java?

人盡茶涼 提交于 2019-12-04 19:05:43
I am running a program in com.me.X.jar . In an external com.me.Y.jar , I have a configuration file located at ' config/conf.txt ' in the root of the Jar. How can I access this configuration file programmatically from within Java? com.me.Y.jar is not currently loaded in memory and is composed of just non-code resources. jar files are just zip files. So google for an example how to read a zip file. Or have a look at the API ZipInputStream The easiest option for reading embedded resources is to use Class.getResource or Class.getResourceAsStream I can think of several ways to achieve this,

Is there a proposal for Resource Bundles in HTML?

≯℡__Kan透↙ 提交于 2019-12-04 17:44:07
Is there a proposal / RFC for resource bundles in HTML? (Or is there already a standard and I have missed the boat?) The concept of resource bundles has worked well with PDF , Java's JAR , Flash's SWF , Android's APK , etc; it seems like WWW is lagging behind here. Here's my informal proposal: Allow bundling of all the page specific resources (images/css/blah blah) into one zip/gzip/bzip2 file. Resources which are common across pages could be put into another bundle, say. Each bundle can have a name and resources could be identified using a URL scheme along these lines: resource://resource