embedded-resource

How to utilize the common image resources in MVC

泪湿孤枕 提交于 2020-01-11 06:55:09
问题 I have several ASP.NET MVC3 and 4 web sites. All sites are using the same resources that are separate to a library. Resources are .resx files. I'd like to use images from these resource in my html inside these sites. I wasn't using resx files before so not sure what is a good way to work with them. I think that I might create a service to provide right image from right resource file, but i guess there should be a better way. My question is what is a good way to use these images from resx

Java Swing ImageIcon, where to put images?

六月ゝ 毕业季﹏ 提交于 2020-01-09 11:07:46
问题 I'm following this tutorial for java swing games: http://zetcode.com/tutorials/javagamestutorial/movingsprites/ At this point: ImageIcon ii = new ImageIcon(this.getClass().getResource()); image = ii.getImage(); I just don't know what kind of path I have to write and where should I save my images (which directory). Would you help me please? Would you give an example? 回答1: In your src folder, create a folder called "images" or "files" then put the image in there. Then use this: ImageIcon(this

Using C#, How to access to a resource file (.resx) and read from a text file added to it?

女生的网名这么多〃 提交于 2020-01-07 05:09:05
问题 I've added a resource file to my project called CrpResource.resx . Then, after adding a text file to the resource file, I wanna to access to it and read from it by code. any suggestion please. 回答1: @Brij has provided the core of the answer. However, the difficult bit here is knowing what the resource name is - it's not always easy after embedding a file as a resource to work out its fully qualified name. An easy way to find out is to add this line temporarily to your code: string[] names =

Simple way to use a jar as a resource archive

与世无争的帅哥 提交于 2020-01-07 03:10:23
问题 So, I'm working on a Java application and I'd like to package resources into jar files to make them more portable. These jar files would be separate from the application and would only contain assets (images, sounds, save files, etc). What's the simplest way to access arbitrary resources from inside a jar file like this? I've looked around a bit, but haven't been able to find any simple tutorials. I know that I can retrieve input streams from a Jar file with a ClassLoader but how do I get a

How to reference a local image in java?

孤者浪人 提交于 2020-01-05 13:08:27
问题 jLabel5.setIcon(new javax.swing.ImageIcon("./i/login.png")); I'm trying to reference that image. The path is correct, and the image actually exists. When I use the full path (I.E. "C:/ blah blah" it works, but this doesn't? The image folder is in the bin folder. 回答1: //This will retuns the URL of the image file inside your project this.getClass().getResource("/i/login.png"); So, your code will be : URL imageUrl = this.getClass().getResource("/i/login.png"); jLabel5.setIcon(new javax.swing

How do I generate a text file during compile time and include its content in the output?

混江龙づ霸主 提交于 2020-01-05 11:49:54
问题 I'm trying to do almost the same as How to create a static string at compile time. build.rs use std::{env}; use std::path::Path; use std::io::{Write, BufWriter}; use std::fs::File; fn main() { let out_dir = env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("file_path.txt"); let mut f = BufWriter::new(File::create(&dest_path).unwrap()); let long_string = dest_path.display(); write!(f, "{}", long_string).unwrap(); } main.rs fn main() { static LONG_STRING: &'static str =

How to extract all String from all Java files in a Java project?

99封情书 提交于 2020-01-03 07:32:15
问题 I need to extract all hard coded Strings values from all Java files in a Java project Into a Java Constant file for example Input // Java file number 1 public class A { public static void main(String[] args) { System.out.println("HardCoded String A"); } } // Java file number 2 public class B { public static void main(String[] args) { System.out.println("HardCoded String B"); } } Output // a Java Constant file public class MyConstants { public static final String HardCodedString_01 =

iTextSharp - How to input image (PNG) from project resource?

耗尽温柔 提交于 2020-01-01 15:56:08
问题 I have iTextSharp creating a pdf for me in VB.net. Everything was working famously, except now I want to embed an image. I tried this: Dim test = My.Resources.MyImage Dim logo = Image.GetInstance(test) This an error though: 'GetInstance' cannot be called with these arguments It appears as though it expects a path, and is getting a System.Drawing.Bitmap type. Is there any way that I can add a project resource image to my PDF? Thanks in advance! 回答1: One of the overloads for iTextSharp.text

Embedded resources in assembly containing culture name in filename will not load

久未见 提交于 2020-01-01 10:05:35
问题 I'm trying to embed some email templates in a class library. This works fine, until I use a filename containing a culture-name with the following notation: templatename.nl-NL.cshtml The resource does not seem to be available. Example code: namespace ManifestResources { class Program { static void Main(string[] args) { var assembly = Assembly.GetExecutingAssembly(); // Works fine var mailTemplate = assembly.GetManifestResourceStream("ManifestResources.mailtemplate.cshtml"); // Not ok,

Embedded resources in assembly containing culture name in filename will not load

落爺英雄遲暮 提交于 2020-01-01 10:05:02
问题 I'm trying to embed some email templates in a class library. This works fine, until I use a filename containing a culture-name with the following notation: templatename.nl-NL.cshtml The resource does not seem to be available. Example code: namespace ManifestResources { class Program { static void Main(string[] args) { var assembly = Assembly.GetExecutingAssembly(); // Works fine var mailTemplate = assembly.GetManifestResourceStream("ManifestResources.mailtemplate.cshtml"); // Not ok,