Append to App.exe.config at run time

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

Guest

Hai All

I am developing a VB application in .NET.

I read a encrypted text file which contains details of SQL Server name, SQL DBName etc... for DB Connection and i prepare a connection string for global use

I also read from a book, that the connection string can be placed in "appname.exe.config" file for windows application. Is there any way to write/append key value pairs into the config file at run time

Thanks
V.Boomessh
 
Hi V,

Did you place this question as well in the newsgroups

microsoft.public.dotnet.language.vb or/and
microsoft.public.dotnet.framework.adonet

(make your subject Connectionstrings and XML and App.config)

For to store an connection string are a lot of places.
An XML datasetfile
A real XML file (see the link from Scorpion)
The registry
A central SQL server
A textfile
A ini file

I prefer the first one.

I know that Scorpion made it for a real XML file.
http://www.kjmsolutions.com/flexibleconnectionstring.htm

I hope this helps?

Cor
 
Hai cor

Thanks for the reply and from the points i gathered from the site you specified, i need to clarigy a question with you again

Is it possible to load the appname.exe.config as an xmldocument and append my server settings key value pair in to it

Thanks
V.Boomessh
 
Hi V,

This is not my direct stuff, I know what you want to do, however it is not
the way I do it.
Ask it again in the newsgroups I pointed you on with the words I suggested.

Cor
 
I read a encrypted text file which contains details of SQL Server name, SQL DBName etc...
for DB Connection and i prepare a connection string for global use.
I also read from a book, that the connection string can be placed in "appname.exe.config"
file for windows application.
Is there any way to write/append key value pairs into the config file at run time.

Not out of the box, no. By default, the myapp.exe.config files are
considered read-only, which makes good sense if you think about it -
they'll be located in the same directory as the app, which normally
isn't one that the average user (at least in a corporate environment)
has write access to anyway.

Since the .config files are nothing but straight XML files, you can
easily write your own class to load the existing XML config file, add
or modify entries, and write the XML file back. MIND YOU: check for
permission to do so!! You might not be able to write it back (since
your user running your app might not have write permission where the
file is located).

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top