I would like to store some images to use in my C# application. They are png files and are currently in a folder with the dlls. Ideally I would like to have them included with the dll so i dont have to include the actual images with the installation.
What is the best way to do this?
I have though about resx but i am unsure as to the best way to go about it. Should I use create the resx file using another project, and then add it to the one I want to use it with?
Thanks in advance.
The easiest is to just add them to your current project and then set their Build Action property to Embedded. I believe that automatically adds them to a resource file and then you can access them using reflection.
Here's an article on retrieving them:
MSDN
Put them in a resource file. You can add it to the same project, no need to create another one.
Related
I am trying to create a .resource file which will contain all the strings being used in the application. I don't want to do it manually.
I know there are certain ways to do it. But my problem is, I don't want to have it done manually, where I need to add each string resource. Is there a way to do this without I having to put each string, and it automatically detects all the strings resources corresponding to different pages.
Any insights on this would be helpful.
Yes, there is a way to do this.
You can try with R#, although the tool is commercial, there is a 30-days trial period.
As a regular user, I can tell you that it worth every cent.
There are suggestion for every string, and moving to the resource file is accomplished by one click.
I am creating ResourceDictionarya and i want to create an enum that contain all the target ResourceDictionary Keys, to use in my code, to reduce the typing errors i tried to make a simpe tool.exe and called it in the Pre-build Action, but i am looking for best way to do that, any one help me please.
thanks in advance.
Consider using T4 templates to get the job done. A T4 template can generate a C# file and you can configure your build to regenerate the file every time.
I am currently developing a solution that has two projects on it: one is some kind of API where I put all the functions that I want to use in the second.
So, at some point in the project, I need to create a file programatically. This is ok, but I need to include that file in my second project to use the functions from the first projects! Any idea on how to do this?
I have tried the EnvDTE but I think it only works if you are creating a new solution and a new project.
Really need help on this! Thanks in advance! :)
Are you literally trying to recompile the second project after creating these files or is this all happening at runtime?
To me it sounds like what you're trying to do is really not create a file but to emit a class in memory during runtime to make new functions available to the second executable. You should check out Reflection.Emit. That is how you define classes, even assemblies, that didn't exist when you started running the program. Check out MSDN and this code project article.
I have a multi-language windows application that uses standard .net localization in resx files.
Now I have a request to add a possibility for user to create his own language files that are not originally supported and add them to the application without recompiling it.
What's the best approach to achieve this?
I'm considering moving the languages to database and then crating a second tool that'll add translations to the database, but would rather keep the current approach, if it's possible to add resx files dynamically.
This is exactly why I don’t use .NET localization but wrote my own.
I store the translations in files separate from the EXE, have a Windows-Forms-based GUI for translation that I can embed in any application (and working on a WPF clone of it), and allow users to switch languages without restarting the application.
I don’t get why anyone would want it any different and why Microsoft created such a bad and limited system.
Unfortunately, I cannot publish my system right now, but I’m hoping I’ll be able to soon.
One option you can use is keep the translations in an XML file. This way, the user can just drop his own XML file into the folder where the translation exists.
You could write the translations to .resx file and just add the location of that file to the database and then when you want to translate some label just go to the database to see where that file is and then read from it. I'm not sure though how it would fit with a localisation lib...
I want to add culture to window application so that it can be used globally.
For this I want to use Only one Resource File.
Right now what I do is adds control manually to that file and reads them at page load.
I want this thing to become automated.
How should I proceed
The .Net model is to use a different dll per culture, so if I understand correctly, you're not going to be able to use .NET i18n.