| re: Accessing config files programatically
The reason there's no API to write to it of course is that your app could be
running under lock-down mode -- no write access to Program Files etc. The
standard pattern is to look for a user-specific file (under Documents and
Settings ... Application Data), and if that can't be found, read the
application one.
"Bruno Jouhier [MVP]" <bjouhier@club-internet.fr> wrote in message
news:%23B31ylA6DHA.3304@tk2msftngp13.phx.gbl...[color=blue]
> The API only allows you to write from it.
>
> In VStudio, you have to create a file called app.config (not
> myapp.exe.config) in your project's base directory and you have to include
> it into your projet (it will be included by default if you create it with
> VStudio but not if you create it outside of Studio).
> Then, when you compile your project, Studio will copy it to bin/Debug or
> bin/Release depending on the config, and it will rename it[/color]
MyApp.exe.config.[color=blue]
>
> Also, don't try to create MyApp.exe.config directly into bin\Debug, it[/color]
will[color=blue]
> get overwritten every time you compile.
>
> Bruno.
>
> "Simon Harvey" <sh856531@microsofts_free_email_service.com> a écrit dans[/color]
le[color=blue]
> message de news:uaUhb0$5DHA.4060@tk2msftngp13.phx.gbl...[color=green]
> > Hi chaps,
> >
> > Can someone direct me to the necessary class that will allow me to write
> > information into my applications .config file? I know how to read
> > information but I'm sure there must be a way to write out to the config[/color]
> file[color=green]
> > easily as well.
> >
> > Also, my application doesnt actually have a config file created by[/color]
> default.[color=green]
> > I thought the VS template would create one automatically but it doesnt.[/color][/color]
Is[color=blue][color=green]
> > it ok just to make one in the form:
> >
> > MyApp.exe.config
> >
> > Will that work?
> >
> > Thanbks everyone
> >
> > Simon
> >
> >[/color]
>
>[/color] |