473,396 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem Adding and Using Resource Files

Hey All,

I am building a solution which will have many strings that will need to be
localized (i.e. strings for toolbars, strings for different WinForms,
strings for messages and error messages, etc.).

I am having trouble accessing string file resources.

What I want to do is to break out strings into separate files so that they
are easier to manage and such that I don't have to look through hundreds to
find, edit or delete something.

How can I use code similar to that below:

Dim rm As ResourceManager
Dim Message as StringBuilder

rm = New ResourceManager("StringTable", Me.GetType().Assembly)

Message = New StringBuilder()
Message.Append(rm.GetString("String1"))
Message.Append(rm.GetString("String2"))
MessageBox.Show(Message.ToString())

Right now, when I try the above I get an error claiming that such resources
cannot be found. The text file is listed under the resources. What's
wrong?

Am I missing something in regards to the structure of the text file or
perhaps how it is added?

Please advise.

Thanks,

TC
Nov 8 '06 #1
4 1842
Am I missing something in regards to the structure of the text file or
perhaps how it is added?
I assume you're using Visual Studio (?). If so then are you aware that it
already has a built-in mechanism to handle strings for you (with relatively
little work on your part)?
Nov 8 '06 #2
Hey Larry,

As I mentioned in the original post, I am using the stings available under
"Resources".

What I am asking for is a way to segregate these strings into intelligent
collections probably via separate files.

That said, how can I load and use separate resource files into the list of
resources?

How can I use code similar to that below:

Dim rm As ResourceManager
Dim Message as StringBuilder

rm = New ResourceManager("StringTable", Me.GetType().Assembly)

Message = New StringBuilder()
Message.Append(rm.GetString("String1"))
Message.Append(rm.GetString("String2"))
MessageBox.Show(Message.ToString())

Regards,

TC
"Larry Smith" <no_spam@_nospam.comwrote in message
news:ul**************@TK2MSFTNGP02.phx.gbl...
>Am I missing something in regards to the structure of the text file or
perhaps how it is added?

I assume you're using Visual Studio (?). If so then are you aware that it
already has a built-in mechanism to handle strings for you (with
relatively little work on your part)?

Nov 8 '06 #3
Hey Larry,
>
As I mentioned in the original post, I am using the stings available under
"Resources".

What I am asking for is a way to segregate these strings into intelligent
collections probably via separate files.

That said, how can I load and use separate resource files into the list of
resources?

How can I use code similar to that below:

Dim rm As ResourceManager
Dim Message as StringBuilder

rm = New ResourceManager("StringTable", Me.GetType().Assembly)

Message = New StringBuilder()
Message.Append(rm.GetString("String1"))
Message.Append(rm.GetString("String2"))
MessageBox.Show(Message.ToString())
What I was alluding to is that you don't need to do this (or rather you're
probably making your life more difficult). First, ".resx" files for forms
are handled automatically by VS (referring to all strings that appear on
your forms for instance). If you're not aware of the details please let me
know (it seems that way). For other resources like error messages and so
forth, go to Solution Explorer and right-click your project's node. Select
"Properties" from the context menu and click "Resources" on the left-hand
side. A table now appears where you can enter all (non-form) resources which
are usually strings (you may have to click on the notice in the middle of
the window first if there is one - it will be present if it's the first time
doing this). VS then creates a wrapper class called "Resources" where you
can now access any single resource (string or whatever) via the
<YourProjectNamespace>.Properties.Resources.<Resou rceNamestatic property
(a "using <YourProjectNamespace>.Properties" statement is required in each
source file of course). For instance, if you add "MyString=Whatever" to the
table and your project's namespace is "YourProjectNamespace", you can do
this:

using YourProjectNamespace.Properties;
// ...
string MyString = Resources.MyString;

You can access all resources this way, not just strings.
Nov 9 '06 #4
Hey Larry,

Yes, I am already using the catch-all resources file and I'm also using the
resource files exposed to userforms.

My question is, if I want to, how can I break the strings in the catch-all
resource out into separate files?

Regards,

Todd

"Larry Smith" <no_spam@_nospam.comwrote in message
news:uw**************@TK2MSFTNGP04.phx.gbl...
>Hey Larry,

As I mentioned in the original post, I am using the stings available
under "Resources".

What I am asking for is a way to segregate these strings into intelligent
collections probably via separate files.

That said, how can I load and use separate resource files into the list
of resources?

How can I use code similar to that below:

Dim rm As ResourceManager
Dim Message as StringBuilder

rm = New ResourceManager("StringTable", Me.GetType().Assembly)

Message = New StringBuilder()
Message.Append(rm.GetString("String1"))
Message.Append(rm.GetString("String2"))
MessageBox.Show(Message.ToString())

What I was alluding to is that you don't need to do this (or rather you're
probably making your life more difficult). First, ".resx" files for forms
are handled automatically by VS (referring to all strings that appear on
your forms for instance). If you're not aware of the details please let me
know (it seems that way). For other resources like error messages and so
forth, go to Solution Explorer and right-click your project's node. Select
"Properties" from the context menu and click "Resources" on the left-hand
side. A table now appears where you can enter all (non-form) resources
which are usually strings (you may have to click on the notice in the
middle of the window first if there is one - it will be present if it's
the first time doing this). VS then creates a wrapper class called
"Resources" where you can now access any single resource (string or
whatever) via the
<YourProjectNamespace>.Properties.Resources.<Resou rceNamestatic property
(a "using <YourProjectNamespace>.Properties" statement is required in each
source file of course). For instance, if you add "MyString=Whatever" to
the table and your project's namespace is "YourProjectNamespace", you can
do this:

using YourProjectNamespace.Properties;
// ...
string MyString = Resources.MyString;

You can access all resources this way, not just strings.

Nov 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
1
by: Stefan Turalski \(stic\) | last post by:
Hi, What I need to do is adding some support for resources files to my application. What I did is: MyAppMain <- startup project MyAppHelper <- project which has MyAppResourcesClass (al a...
0
by: Rob | last post by:
Hi Visual Studio.NET 2002 v7.0 Windows XP (all service packs up to date) Working on Clearcase MVFS mapped drive. When compiling my ATL control, I always have to hit Rebuild Solution. If I...
7
by: Wysiwyg | last post by:
Is there any way to add an embedded resource to a project without copying it to the project's directory? I have shared resources and don't want each project using the images, xml files, etc. to...
2
by: Rob Garfoot | last post by:
I'm hoping someone here can help with this one as I've been looking all around for a solution to this and I've yet to find one that is satisfactory. I'm trying to add support for different...
1
by: E. Tom Jorgenson | last post by:
I've run into a problem on a couple of projects that I think I've identified - but would like confirmation of what I think is going on. Also interested in any fast solutions to fix the user...
4
by: TCook | last post by:
Hey All, I am building a solution which will have many strings that will need to be localized (i.e. strings for toolbars, strings for different WinForms, strings for messages and error messages,...
0
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I have some web pages and user controls (ASCX), I switched my user control to Design View in my VS 2005 (SP1), I chose "Tools --Generate Local Resource" menu to create resource files. ...
5
by: DBC User | last post by:
I have a situation, where I need to add 4 or 5 data files (they change every time I build) in my project during build time and somehow I need a way to access these files during runtime. So I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.