Home »

How do I write to the application configuration file at runtime?Why Writing Into .NET Application Configuration Files Is a Bad Idea

Question ListCategory: .NETHow do I write to the application configuration file at runtime?Why Writing Into .NET Application Configuration Files Is a Bad Idea
denielshakespeare5 author asked 8 years ago
1 Answers
jamessmith05 author answered 8 years ago

.NET applications can have a configuration file associated with them. In web apps, the file is called web.config. For a normal Windows or console application, it is has the same name as the executable with .config tacked on the end. So if your app is called Foo.exe, you would put the configuration file in the same directory and call it Foo.exe.config. In Visual Studio .NET projects, the file will be called App.config – VS.NET copies it into your build output directory and changes the name appropriately.
.NET itself looks for certain settings inside this file. For example, the assembly resolver can be configured this way. It can also be used to store some application-specific settings in its element.

Please login or Register to Submit Answer