471,319 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Store program data

Hi everyone.

I would like to ask about good habid, of keeping program data.
I have written in C# Server and Client applications, and now i need to
care about authorization.
What i mean is that Server should allow login only authorized users -
Admin of the server should have good and comfortable acces to
"permitted users list", with opportunity to add or remove entries in a
good way.
Program should also keep info. where to store received files. This is
also the thinkg that might by changed by administrator of the server.

Where and how o keep this informations.
Should i use XML, or create ini file. Where to place this files.
Program directory or somwhere else.
Thank you for your time and advice.
PK

Dec 3 '05 #1
4 3840
Generally speaking, configuration settings such as where to store files are
kept in the app configuration file. If you add an app.config file to your
project, this will be automatically converted / deployed to the build folder
as yourapp.exe.config. You can either use the appSettings section or a custom
config section to read these settings.

Regarding authentication data such as username / password pairs, unless you
have only a small amount of data, the best place to store this is in a
database and create a method that looks this up based on login parameters
supplied by the user.

Theses are not the only ways to store such data, but hopefully they give you
some ideas.

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Piotrekk" wrote:
Hi everyone.

I would like to ask about good habid, of keeping program data.
I have written in C# Server and Client applications, and now i need to
care about authorization.
What i mean is that Server should allow login only authorized users -
Admin of the server should have good and comfortable acces to
"permitted users list", with opportunity to add or remove entries in a
good way.
Program should also keep info. where to store received files. This is
also the thinkg that might by changed by administrator of the server.

Where and how o keep this informations.
Should i use XML, or create ini file. Where to place this files.
Program directory or somwhere else.
Thank you for your time and advice.
PK

Dec 3 '05 #2
Thanks. That's the way i will implement this.
BTW.
I have added config file, as you explained.
It's of the form:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<AppSettings>
<add key="Key1" value="Kevin" />
<add key="Key2" value="150" />
<add key="Key3" value="Rice" />
</AppSettings>
</configuration>

Then i try to receive some keys from xml by:
String ppp =
System.Configuration.ConfigurationSettings.AppSett ings["Key1"];

Am i doing something wrong? I found this example on the internet, (
manually added config file ).
Anyway ppp == null
PK

Dec 3 '05 #3
The config file must be named "app.config" and be included in your project to
be translated into yourapp.exe.config and placed next to the built executable
after a build or in an F5 debug operation.
you might have to cast values as (string) when pulling them out with the
code you show. Otherwise, I can't see anything wrong with it except for the
fact that your appSettings element has a Capital "A". It needs to read
"appSettings".
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Piotrekk" wrote:
Thanks. That's the way i will implement this.
BTW.
I have added config file, as you explained.
It's of the form:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<AppSettings>
<add key="Key1" value="Kevin" />
<add key="Key2" value="150" />
<add key="Key3" value="Rice" />
</AppSettings>
</configuration>

Then i try to receive some keys from xml by:
String ppp =
System.Configuration.ConfigurationSettings.AppSett ings["Key1"];

Am i doing something wrong? I found this example on the internet, (
manually added config file ).
Anyway ppp == null
PK

Dec 3 '05 #4
Now it works.
Thank you for your time.
PK

Dec 3 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by noridotjabi | last post: by
10 posts views Thread by Paul Cheetham | last post: by
reply views Thread by Brian Vanderburg II | last post: by
reply views Thread by rosydwin | last post: by

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.