-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Sanjay
Message 1 in Discussion

Hi,

I think we can use following two ways to access values in appSettings section in 
application config file (Win Form applications):

1. Use static property AppSettings of ConfigurationSetting class
2. Create an instance of AppSettingsReader class and use GetValue method

Which is better way to access the config file? 
When should we use a particular method?

Another question is: If we want to put a check in the application to ensure that 
config file exists - what should we do?

The AppSetting property of ConfigurationSetting class return null for the value we are 
looking for, if file does not exist.

And GetValue method raises InvalidOperationException in this case. But this exception 
gets raised for number of other reasons also like: required key does not exist in 
file, the specified type does not have parser etc?

So if I want to report to user that config file does not exist, is using "File.Exists" 
the only way to do that? Or BCL provided us some inbuilt method for that?

Thanks,
Sanjay


-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to