Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I found PlausiblyDamp's post about reading from the app.config file, which is rather nice.

 

Dim appConfig As New Configuration.AppSettingsReader
	Label1.Text = appConfig.GetValue("ConnectionString", GetType(String)).ToString()

 

Thats all the code you need to get into a setting, thats very nice.

 

How about writing to an AppConfig file, once you have the settings in place, if the settings are changed during runtime?

 

say during runtime, I had an option were the user could change the "ConnectionString" (most likely just the path and/or password) and I wanted to save it?

 

I'm sure this wouldn't be terribly hard to write a procedure that would accept two parameters to tell it which tag to find and what setting to place there, but is there a standard way?

 

I've heard about XML Serialization, but this seems much easier at the moment :)

  • Administrators
Posted

The application.config file is really designed as an administrative feature - it allows you to move key settings out of the application code (and away from things like the registry) to allow an admin to reconfigure the app after deployment. It isn't really designed to be modified from within the application itself - one major reason is security: on XP pro and better then a normal user doesn't have write permissions to the applications folder and any update would fail (or all users would have to be admins :eek: ).

Serialisation is fairly easy when you look at it and through this method you could store settings either per user or per machine via the OS's profiles.

Not near VS at the moment but I think you can get to a list of these through Environment.SpecialFolders or similar.

If you require any help with serialisation then feel free to ask here.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...