Re: Append to App.exe.config at run time

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Marc Scheuner [MVP ADSI] (m.scheuner_at_inova.SPAMBEGONE.ch)
Date: 06/03/04


Date: Thu, 03 Jun 2004 07:52:35 +0200


>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



Relevant Pages

  • Re: Append to App.exe.config at run time
    ... I generally think of the app.config as holding static information that the ... > I read a encrypted text file which contains details of SQL Server name, ... > I also read from a book, that the connection string can be placed in ... write/append key value pairs into the config file at run time. ...
    (microsoft.public.dotnet.distributed_apps)
  • .NET and SQL Server on Separate Machines
    ... Everything was running correctly when the database ... IIS V6 on Win2000 and SQL Server 8on Win ... The connection string in our web.config file originally looked like this: ... This string only works if we add the following to the .config file: ...
    (microsoft.public.dotnet.framework.adonet)
  • .NET and SQL Server on Separate Machines
    ... Everything was running correctly when the database ... IIS V6 on Win2000 and SQL Server 8on Win ... The connection string in our web.config file originally looked like this: ... This string only works if we add the following to the .config file: ...
    (microsoft.public.sqlserver.connect)
  • Re: One Connection String for Multiple Users (SQL)
    ... Hitchhiker’s Guide to Visual Studio and SQL Server ... "William Vaughn" wrote: ... This uses the> same connection string for all instances of the application. ...
    (microsoft.public.sqlserver.connect)
  • RE: How do I configure Analysis Services for Excel 2003 users?
    ... they had had Office 2003 installed AFTER SQL Server. ... > I have been preparing a set of cubes in Analysis Services 2005 to be viewed ... > Excel reports have been designed as pivot tables based on AS cubes, ... > Surely it must be that the connection string is incorrect but I seem to have ...
    (microsoft.public.sqlserver.olap)