By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,474 Members | 3,139 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,474 IT Pros & Developers. It's quick & easy.

Store program data

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.