473,804 Members | 4,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Where to store string messages?

Hi.

Almost every application have to write out some messages to the user.
The question is how to store them. For example, while programming for
Windows in C++ we could store these messages as string resource and
load them using LoadString API function. I'm quite new to C#, and the
best thing I've managed is creating private constant members of a
class. E. g.:

public class ExpandManager
{

....

#region Message declarations

private const string ERR_NOSUCHFILE = "File not found: ";
private const string ERR_EMPTY = "The selected workbook seems to be
empty.";
private const string ERR_LOCATECOL = "Couldn't locate the column
with area codes.";
private const string MSG_OPEN = "Opening source";
private const string MSG_CALCDIMS = "Obtaining ratelist
dimensions";
private const string MSG_PREPAREOUT = "Preparing output workbook";
private const string MSG_EXPAND = "Expanding code intervals";

#endregion
}

Isn't there an elegant way to solve this issue?

Thanks in advance

Martin

Oct 20 '06 #1
2 2449

Right click the project and select "Add New Item". Select Resources
File. It is essentially an XML file with the resx extension. VS2005
will auto-generate an internal class with the name same as the
resources file, and all you have to do is calling its static
properties. Very easy, try it out.

If you are using VS2003, the IDE does not generate the class for you so
you have to write code to access resources your own with the help of
System.Resource s.ResourceManag er class.

martin-g wrote:
Hi.

Almost every application have to write out some messages to the user.
The question is how to store them. For example, while programming for
Windows in C++ we could store these messages as string resource and
load them using LoadString API function. I'm quite new to C#, and the
best thing I've managed is creating private constant members of a
class. E. g.:

public class ExpandManager
{

...

#region Message declarations

private const string ERR_NOSUCHFILE = "File not found: ";
private const string ERR_EMPTY = "The selected workbook seems to be
empty.";
private const string ERR_LOCATECOL = "Couldn't locate the column
with area codes.";
private const string MSG_OPEN = "Opening source";
private const string MSG_CALCDIMS = "Obtaining ratelist
dimensions";
private const string MSG_PREPAREOUT = "Preparing output workbook";
private const string MSG_EXPAND = "Expanding code intervals";

#endregion
}

Isn't there an elegant way to solve this issue?

Thanks in advance

Martin
Oct 20 '06 #2

Truong Hong Thi wrote:
Right click the project and select "Add New Item". Select Resources
File. It is essentially an XML file with the resx extension. VS2005
will auto-generate an internal class with the name same as the
resources file, and all you have to do is calling its static
properties. Very easy, try it out.

If you are using VS2003, the IDE does not generate the class for you so
you have to write code to access resources your own with the help of
System.Resource s.ResourceManag er class.
Thank you. I'm using VS2005 and things are really very easy. I wonder
how could have missed this feature :).

Oct 20 '06 #3

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

Similar topics

2
3749
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into the appropriate array. For instance if I receive a RCVD_MSG1, I'll copy into msg1 . Upon receipt of the next RCVD_MSG1. I'll copy into msg1 . The Retrieve function when called should retrieve the latest copy. ie. msg1 or msg1 .
17
5054
by: Jonas Rundberg | last post by:
Hi I just started with c++ and I'm a little bit confused where stuff go... Assume we have a class: class test { private: int arr; };
4
3409
by: gerry | last post by:
I have an async OnStore event written in c# and registered in exchange 2003. Everything seems to be working fine other than the SaveToFile(). If there is an error in the iMessage.DataSource.Open ( ie. the message has moved ) the expected exception is raised and caught. However when the strm.SaveToFile() is executed the process just seems to die - no output file is generated , no exceptions raised , no system log entries , no more log()...
6
2041
by: ad | last post by:
We usually store the connection string of Web Applicaiton in Web.Config. Now I want to develop WinForm Application. Where is the better place to store the conneciton string?
10
4284
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version. Because of this, I am unable to store these settings in the App.Config file, as this gets updated every time the application does, and there doesn't appear to be a way of preventing this. Most of my application settings are kept in the...
18
9162
by: siddharthkhare | last post by:
Hi All, what is the diference between these two cache control header. no-cache and no-store. I have read the w3.org explanation. So lets say I am using only no-cache ....my understanding is that nothing is cached and nothing is writen to disk.
0
889
by: Jarod | last post by:
Hey I need to share data from many users ( Chat application ). What's the best place to store last 30 messages ? Static generic list's ? Where to store user specific data like logins and last message date ? Is there any choice from session, cookie and so on ? And if not what's best for it ? I'll be using Atlas to update user page. Jarod
4
2039
by: Rob | last post by:
The app.config in VB 2005 appears to be riddled with bugs.... From solution explorer I right click on the Project | Properties... then I use the grid to add the app settings... AND they are saved in the app.config.xml as well, however, the program uses the value that were originally stored in the settings. I have run the Build and Saved the file, I even exited and re-opened the program as well as rebooted the machine.
3
1596
by: | last post by:
I want to write some custom error messages to a log so that I can read them on the next run of the application and as the user to send them to me. Where the right place to store this log file? Which directory path is the right one - so that it's always writable regardless of the user's permissions. I guess it's more of an application-level log than a user-level log. Or maybe not. Is there an up-to-date (e.g. .NET 3.5/Vista specific)...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10320
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9150
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.