properties and other files in a .net world

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Two questions:

First:

In the java word you have an ProjectName.properties file and you can place
it lots of different places - in the file system with the jar file, in the
ProjectName.jar file, or elsewhere and use a -Dprop_location=xxx to identify
it.

It seems to me that in the .net world this file is ProjectName.dll.config
and that file is in the file system with ProjectName.dll - and that is the
only option. I know you could do other things - but it seems to me that this
is the only way it is "supposed" to be done.

Second:

In the java environment I have another file (an xml file) that I stuff in
the ProjectName.jar file and just access from there when needed. Where should
I place this?

I don't want to put it in ProjectName.dll.config because it would be a very
big cdata[]] block Should I make it a dll resource?

??? - thanks - dave
 
It would be nice if you tell us what you want to do with these files, so we
could advice the best solution!

Not knowing what you want to do, here is a general answer:

In .NET you could stuff your assembly with any file you like, which you
later access with a syntax like
Stream s =
GetType().Assembly.GetManifestResourceStream("path/to/my/file/name.extension");
or
Stream s =
GetType().Assembly.GetManifestResourceStream("path.to.my.file.name.extension");

if you want to put resource (particularly internationalizable resource), you
better place them all in a .resx file, which will be embed in your app.
the .resx file is typicall accessed through a ResourceManager class. Note
that VS.NET2005 provide very nice integration so that you could directly
call their resource by name as in
myResource.IconTurtle;
To internationalize just create satelite assembly with the internationalized
content of these files.

Also you spoke of a second file which looks like a config file.
This file is the App.config, although it's renamed by VS.NET (or manually by
you) <appname.exe>.config
This is the one to contains the 'standart format' app's configuration (look
in documentation for ConfigurationManager).
Although you could use any config file you like, these file are already
packaged with tons of features and a nice integration into the framework.
 
Stuffing it in the assembly is a great idea - thank you.

The xml file holds the properties to use when creating charts, a set of
properties for each color scheme. So there is no internationalization
involved.

--
thanks - dave


Lloyd Dupont said:
It would be nice if you tell us what you want to do with these files, so we
could advice the best solution!

Not knowing what you want to do, here is a general answer:

In .NET you could stuff your assembly with any file you like, which you
later access with a syntax like
Stream s =
GetType().Assembly.GetManifestResourceStream("path/to/my/file/name.extension");
or
Stream s =
GetType().Assembly.GetManifestResourceStream("path.to.my.file.name.extension");

if you want to put resource (particularly internationalizable resource), you
better place them all in a .resx file, which will be embed in your app.
the .resx file is typicall accessed through a ResourceManager class. Note
that VS.NET2005 provide very nice integration so that you could directly
call their resource by name as in
myResource.IconTurtle;
To internationalize just create satelite assembly with the internationalized
content of these files.

Also you spoke of a second file which looks like a config file.
This file is the App.config, although it's renamed by VS.NET (or manually by
you) <appname.exe>.config
This is the one to contains the 'standart format' app's configuration (look
in documentation for ConfigurationManager).
Although you could use any config file you like, these file are already
packaged with tons of features and a nice integration into the framework.



--
If you're in a war, instead of throwing a hand grenade at the enemy, throw
one of those small pumpkins. Maybe it'll make everyone think how stupid war
is, and while they are thinking, you can throw a real grenade at them.
Jack Handey.
David Thielen said:
Two questions:

First:

In the java word you have an ProjectName.properties file and you can place
it lots of different places - in the file system with the jar file, in the
ProjectName.jar file, or elsewhere and use a -Dprop_location=xxx to
identify
it.

It seems to me that in the .net world this file is ProjectName.dll.config
and that file is in the file system with ProjectName.dll - and that is the
only option. I know you could do other things - but it seems to me that
this
is the only way it is "supposed" to be done.

Second:

In the java environment I have another file (an xml file) that I stuff in
the ProjectName.jar file and just access from there when needed. Where
should
I place this?

I don't want to put it in ProjectName.dll.config because it would be a
very
big cdata[]] block Should I make it a dll resource?

??? - thanks - dave
 
Hi

Did Lloyd's suggestion help you?
In .NET we use config file to store application configuration, if you want
to stored resource, it can be stored in the assembly.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top