How to create text file for Resource file
-
Hi, I want to use resource files to store message box strings. Which I read that I can by defining Name = value pair in text file. like ex > Close = "Really wann quit this application". But now the problem is where should I wirte this text file and then where should I compile Resgen myResource.txt , to create myResource.resource file. Now after doing all this how should I use these Name of string in my application to call resource file. Thanx for ur support. Inpreet Singh
-
Hi, I want to use resource files to store message box strings. Which I read that I can by defining Name = value pair in text file. like ex > Close = "Really wann quit this application". But now the problem is where should I wirte this text file and then where should I compile Resgen myResource.txt , to create myResource.resource file. Now after doing all this how should I use these Name of string in my application to call resource file. Thanx for ur support. Inpreet Singh
As I've been trying to tell you in an old thread, use a ResX file in VS.NET instead and mark it as an embedded resource. Forms and controls already have a hidden ResX file associated with them. You can use .txt files but you'll have to compile them manually - like I also said before - using resgen.exe to the appropriate name (fully-qualified name) and embedding them with the csc.exe compiler using the /res option. If you use a ResX file, you can centralize/localize more than just string resources, including various structs and classes that have a
TypeConverter
associated with them. I also gave you a link to check out that shows MANY examples of using theResourceManager
and even a code snippet, which I'll post again:ResourceManager resources = new ResourceManager(typeof(SomeClass));
Use the code above is a .resources file would have the same namespace and name (fully-qualified name) as a class. If now, you have to use the name and get the assembly, something like:
ResourceManager resources = new ResourceManager("MyResources.resources", this.GetType().Assembly);...where `this` is an instance of your class that will use the resources. You need to get the `Assembly` and this is one of many ways to do it (one of the faster ways). Here's [that link](http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemResourcesResourceManagerClassTopic.asp)[[^](http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemResourcesResourceManagerClassTopic.asp "New Window")] again for the `ResourceManager` class. Microsoft MVP, Visual C# [My Articles](http://www.codeproject.com/script/articles/list_articles.asp?userid=46969)