embedded-resource

Why getResourceAsStream method is in Class class?

只愿长相守 提交于 2020-01-01 09:27:50
问题 Why public InputStream getResourceAsStream(String name) is in Class class? It just give inputstream of file which is in jar file and there is no relation with Class class. so it can be static method and it can be in any class. 回答1: There is a relationship to the class: The package of the class is taken into account - if you give call getResourceAsStream("baz.txt") on the class for foo.bar.SomeClass it will look for /foo/bar/baz.txt The classloader is taken into account to find the resources

Loop through embedded resources of different languages/cultures in C#

早过忘川 提交于 2020-01-01 09:17:09
问题 One level up from this question, what would be the way to store all (and loop through) available resources and associated cultures, to allow user selection of a specific culture? Further explanation: Suppose three resource files: GUILanguage.resx GUILanguage.fr.resx GUILanguage.it.resx I could have a string in each called LanguageName . How would I be able to programmatically loop through the different LanguageName values to list them (in say a list box)? EDIT: WinForms project, embedded

ASP.Net MVC 3 accessing CSS, JS files from separate DLL

Deadly 提交于 2020-01-01 03:39:36
问题 I'm following this link, compile razor files into separate dll, and can get it to work except I can't figure out how to access JavaScript, CSS, and Images embedded in the dll. Has anyone used this approach? It seems very promising. Thanks. 回答1: The technique presented in this article is for embedding razor views into separate assemblies. It doesn't allow you to do so with static resources such as images, js and CSS. For those type of resources you will have to implement a custom solution. For

Adding a big text file to assets folder

谁都会走 提交于 2019-12-30 10:34:23
问题 I'm developing an Android 2.2 application. I want to add some big text files (4.5MB or more) to Android project. First I don't know if I can add such kind of big files to assets folder. But, if I can, is it possible to compress them? How can I compress files? and decompress? Any other better way to add big text files to Android project? Thanks. 回答1: Files over 1 MB placed in the assets folder won't be readable from your app (It'll throw an exception). This is because they get compressed

How can I extract a resource into a file at runtime?

徘徊边缘 提交于 2019-12-30 08:04:48
问题 I want to distribute only a single .exe, however, at runtime I would like it to extract some embedded image resources to the users hard disk drive. Can I, and if so, how? 回答1: Use Delphi's TResourceStream. It's constructor will find and load the resource into memory, and it's SaveToFile method will do the disk write. Something similar to this should work: var ResStream: TResourceStream; begin ResStream := TResourceStream.Create(HInstance, 'YOURRESOURCENAME', RT_RCDATA); try ResStream.Position

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

大城市里の小女人 提交于 2019-12-30 07:57:13
问题 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

Read Extension of file in resources

故事扮演 提交于 2019-12-30 07:27:09
问题 How can I write a code to read the extension of a My.Resources file? Example: if i have a file named IMG.JPEG in my resources How can I make msgbox to show the extension .JPEG ? I can show the file name but without extension with this For Each Fe In My.Resources.ResourceManager.GetResourceSet _ (System.Globalization.CultureInfo.CurrentCulture, False, True) MsgBox(Fe.Key) Next any help would be greatly appreciated EDIT: I can get the extension of file but as .BYTE[] and pictures as .Bitmap

Accessing image paths in Eclipse

梦想的初衷 提交于 2019-12-30 07:22:16
问题 I'm trying to access some images in my Java code. The code to call the images is below. public final ImageIcon whitePiece = new ImageIcon(getClass().getResource("Images/whitecircle.PNG")); public final ImageIcon blackPiece = new ImageIcon(getClass().getResource("Images/blackcircle.png")); public final ImageIcon tiePiece = new ImageIcon(getClass().getResource("Images/tiecircle.PNG")); public final ImageIcon boardPic = new ImageIcon(getClass().getResource("Images/gameboard.PNG")); However, this

Accessing image paths in Eclipse

痞子三分冷 提交于 2019-12-30 07:22:08
问题 I'm trying to access some images in my Java code. The code to call the images is below. public final ImageIcon whitePiece = new ImageIcon(getClass().getResource("Images/whitecircle.PNG")); public final ImageIcon blackPiece = new ImageIcon(getClass().getResource("Images/blackcircle.png")); public final ImageIcon tiePiece = new ImageIcon(getClass().getResource("Images/tiecircle.PNG")); public final ImageIcon boardPic = new ImageIcon(getClass().getResource("Images/gameboard.PNG")); However, this

RazorEngine string layouts and sections?

≯℡__Kan透↙ 提交于 2019-12-29 14:19:44
问题 I use razor engine like this: public class EmailService : IService { private readonly ITemplateService templateService; public EmailService(ITemplateService templateService) { if (templateService == null) { throw new ArgumentNullException("templateService"); } this.templateService = templateService; } public string GetEmailTemplate(string templateName) { if (templateName == null) { throw new ArgumentNullException("templateName"); } Assembly assembly = Assembly.GetAssembly(typeof(EmailTemplate