By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

create app.config during runtime from within code

P: n/a
can someone explain me how to create a app.config file during runtime? i see
two ways:

- add a skeleton of an app.config file to the exe/dll and extract it during
runtime as a resource and extract
OR
- create a app.config file using xml

is there another way?

thanks

christian

Dec 30 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Christian,

Well, if you really want to get rudimentary, you could create a
FileStream instance and write it byte by byte.

But I doubt you want to do that.

Usually, the configuration sections have object models that you can
access through the classes in the System.Configuration namespace. You could
try working with these models in code and then persist them to another file
(although because config files are not written to, except for user setting
sections, it might be the case that there is not much support for going from
the config object to XML, only vice versa).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Christian Muggli" <christian.muggliATgmail.comwrote in message
news:55**********************************@microsof t.com...
can someone explain me how to create a app.config file during runtime? i
see two ways:

- add a skeleton of an app.config file to the exe/dll and extract it
during runtime as a resource and extract
OR
- create a app.config file using xml

is there another way?

thanks

christian
Dec 30 '07 #2

P: n/a
You could certainly keep a bare-bones config file as an embedded resource and
extract and save it next to the executable. You could also use the classes in
System.Configuration to work with, edit and resave your modified config file.
But that's with the proviso that the app only loads an existing config file
one time - when it's first run. So you'd need some mechanism to force it to
be reloaded once modified, unless you plan on only having it take effect when
the application is restarted.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Christian Muggli" wrote:
can someone explain me how to create a app.config file during runtime? i see
two ways:

- add a skeleton of an app.config file to the exe/dll and extract it during
runtime as a resource and extract
OR
- create a app.config file using xml

is there another way?

thanks

christian
Dec 30 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.