"string resource file" in c#?

  • Thread starter Thread starter Dan H.
  • Start date Start date
D

Dan H.

Hello,
What is the equivalent "string resource file" in c#?

And, is there a way to create a beep in C#?

Thanks,
Dan
 
Hi Dan,
What is the equivalent "string resource file" in c#?

I don't think there is equivalent of string resource since you can embed
whatever stream you want into a assembly. My suggestion is to use XML file
for keeping the strings. If you need language specific versions of the
strings you can use satellite assemblies, which will contain different
versions of that xml file.
And, is there a way to create a beep in C#?
There is no class in the current vesrion of the framework providing this.
You have to use P\Invike to call MessageBeep or whatever other API function
you want. If search the net I believe there are tons of examples how to do
beeps.

HTH
B\rgds
100
 
Hi Dan,

If your purpose is internationalization and localization, with .NET,
Microsoft (finally) provides truely excellent support. (Even if you want a
string resource for some other reason, these features will do the trick for
you.) Take a look at the Localizable property on the Form properties
window. Turn it on and all form and control properties will be stored in a
separate resources file. Take a look at the InitializeComponent() code to
see how it works. In addition, Microsoft provides a WinRes.exe resource
editor that lets localizers edit these properties without having access to
the code. Since the resource is an XML file (e.g. Form1.resx file) you can
use any XML editor to modify its contents if you'd like.

In addition, .NET supports the creation of multiple resource files using a
hierarchical model. There is a basic invarient resource, then ones that are
language specific, then ones that are dialect specific and so forth. All of
this is supported in the default Form, so you can explore these features in
the Form properties. For example, try setting the Language to French and
see what happens.

Tom Clement
Apptero, Inc.
 
What is the equivalent "string resource file" in c#?
Yes.
The .NET string resource file looks like the Java properties
(id=string), but the encoding uses UTF8 instead of Java escape.

The extension is .txt (I think a bad idea), and can be compiled
with ResGen to a .resources file
You can also use .resx files (xml format)
ResGen is able to convert between .resx, .txt and .resources
(but if the resx contain forms, images, etc, it will drop them)

Mihai
 
Dan H. said:
Hello,
What is the equivalent "string resource file" in c#?

If the purpose is for Localization, simply set your form's Localizable
property to true and then change the Language property to whatever language
you want and start changing the control's text. The locailization
information will be stored in the language specific resx files.
And, is there a way to create a beep in C#?

Include the following in your class file to 'Beep'

[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int MessageBeep(uint n);
 
Is any of this possible (reasonably easily :-)) without VS.Net? I am
using SharpDevelop 0.98 (free VS.Net lookalike), and trying to get
something working similar to what is in VS.Net. Ya, I know, just buy
VS.Net :-) But I am cheap.

It seems like what I need is basically a resource editor that
generates .resx files (including stuff like size of Dialog boxes,
etc), but am still naive about how all this resource stuff works.

Any one have any experience with this?

Thanks,

Joe
 
SharpDevelop makes the full framework available to you.

To generate .resx files, use code something like this:

ResXResourceWriter rw = new
ResXResourceWriter(@"C:\myFullPathAndFileName + ".resx");
rw.AddResource("Key", value);
//add more key/value pairs, etc.
rw.Generate();
rw.Close();

you need a using statement like:
using System.Resources;

and you need to ref the WinForms DLL
 
Back
Top