Sauron
Sauron

Reputation: 16923

Create app.config file dynamically on Application startup

How can I create the app.config file programatically on Application startup (if the file doesnot exist)?

Upvotes: 1

Views: 1768

Answers (3)

Richard
Richard

Reputation: 109170

You can save changes to configuration (by using configuration in the right way). This will create files at user-local or user-roaming levels, I expect it will at application level as well.

But consider that the user running the application will only be able to do this is he/she has sufficient access to the installation directory—this will not normally be the case (and will likely require UAC escalation).

Upvotes: 0

BerggreenDK
BerggreenDK

Reputation: 5004

I'm not sure, but it's it more appropriate to make your program handle that exception and then use default-values unless there is an app.config?

Upvotes: 0

Josip Medved
Josip Medved

Reputation: 3711

Since that file is just standard XML, you could just use XmlTextWriter to create it.

Upvotes: 2

Related Questions