resources

Enumerating .NET assembly resources at runtime

江枫思渺然 提交于 2019-12-17 06:10:13
问题 I have a resource assembly with image files in it that are built using Resource or Content build action. This makes these files accessible using the Uris. However I cannot find the way to enumerate such resources. If I set the build action to Embedded Resource it becomes possible to enumerate the files with the following code: string[] resources = Assembly.GetExecutingAssembly().GetManifestResourceNames(); but it in turn makes these files inaccessible using Uris. The question is - how to

How can I discover the “path” of an embedded resource?

老子叫甜甜 提交于 2019-12-17 03:53:24
问题 I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this: Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png"); The file, named "file.png" is stored in the "Resources" folder (within Visual Studio), and is marked as an embedded resource. The code fails with an exception saying: Resource MyNamespace.Resources.file.png cannot be found in class MyNamespace.MyClass I have identical code (in a different assembly, loading a

REST Complex/Composite/Nested Resources [closed]

落爺英雄遲暮 提交于 2019-12-17 03:44:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I'm trying to wrap my head around the best way to address concepts in a REST based API. Flat resources that don't contain other resources are no problem. Where I'm running into trouble are the complex resources. For instance, I have a resource for a comic book. ComicBook has all

How to clear an ImageView in Android?

╄→尐↘猪︶ㄣ 提交于 2019-12-17 03:23:56
问题 I am reusing ImageView s for my displays, but at some point I don't have values to put it. So how to clear an ImageView in Android? I've tried: mPhotoView.invalidate(); mPhotoView.setImageBitmap(null); None of them have cleared the view, it still shows previous image. 回答1: I used to do it with the dennis.sheppard solution: viewToUse.setImageResource(0); it works but it is not documented so it isn't really clear if it effects something else in the view (you can check the ImageView code if you

Get path of Android resource

旧时模样 提交于 2019-12-17 03:17:25
问题 My question is: is it possible to get the absolute path of a resource (in a subdirectory of the res/ folder) in Android? Most of the answers I see to this question on google suggest getting a file descriptor, implying that this is not possible. Is it? EDIT: The reason I want to do this is because I'm writing classes that accept a path to media and play it. Testing would be much easier if I could pass the absolute path of a resource. 回答1: Use URI Paths instead of "absolute" path, see this post

open resource with relative path in java

二次信任 提交于 2019-12-17 02:33:37
问题 In my Java app I need to get some files and directories. This is the program structure: ./main.java ./package1/guiclass.java ./package1/resources/resourcesloader.java ./package1/resources/repository/modules/ -> this is the dir I need to get ./package1/resources/repository/SSL-Key/cert.jks -> this is the file I need to get guiclass loads the resourcesloader class which will load my resources (directory and file). As to the file, I tried resourcesloader.class.getClass().getResource("repository

Proper way to close an AutoCloseable

巧了我就是萌 提交于 2019-12-17 02:32:14
问题 What is the most reliable pattern to follow when closing an OutputStream, ServerSocket, or other object that implements the AutoCloseable interface? Should I use try - catch - finally ? Or a shutdown hook. 回答1: The correct way to use an AutoCloseable instance is with a try-with-resources block, so the resource is reliably closed even if an exception is thrown. Like this: try (OutputStream stream = new ...) { ... // use the resource } catch (IOException e) { ... // exception handling code }

Implementation of industry specific resources

烂漫一生 提交于 2019-12-14 04:21:49
问题 We have a program that is used in one specific industry and has strings that are specific to that industry. We now have the situation where it can be used in another industry and we want to customise the strings for that industry without duplicating our code base. The problem space appears very similar to localisation. Are we going to have a separate resource assembly for each industry? If so when would we choose which assembly to use, could we do this at install time or would it need to be

IntelliJ Idea + JavaFX = class.getResource() returns null

倖福魔咒の 提交于 2019-12-14 03:56:22
问题 I know, there are lots of similar question around here with similar problems, but after reading tons of posts, I cannot simply solve this issue. Under Compiler > Resource Patterns , I've already put this string "*.fxml". Moreover, I've marked the resources folder as the Resources Root. Here you can see my project structure: This is my MainView.java class. package dataParser.View; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx

Change value of R.string programmatically?

本小妞迷上赌 提交于 2019-12-14 03:53:04
问题 I'm looking for a way to change the value of a string resource dynamically. I have tried to use reflection but it claims 'invalid value for field'. I use the strings for values within the layout, but need to swap them out for different languages. Please see the attached code below. public class Lang{ public static void langInit(){ java.lang.reflect.Field[] langStringFields = R.string.class.getFields(); Log.d(Global.TAG,"--> Lang Listing: " + langStringFields.length); Log.d(Global.TAG,"-->