Configuration Files
-
I am planning the design of a small app (read: a few hundred lines, fast execution). The app will run behind the scenes with no user I/O. I am looking into configuration files and I was considering using a local .ini or .xml file. Question: Which should I use? (Subquestion: should I use one?). The settings would probably only include a few crucial settings and due to the nature or the beast, a few of those would need to be encrypted (password fields or so.) Looking at the problem now I'm thinking it may be far simpler to just hard-code the user names and passwords into the file, but I hate doing that. XML would be fast and easy but it's large and unnecessary while .ini files would be the proper size but I don't know about any facilities for encryption at the field level. Any suggestions? Thanks. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams
-
I am planning the design of a small app (read: a few hundred lines, fast execution). The app will run behind the scenes with no user I/O. I am looking into configuration files and I was considering using a local .ini or .xml file. Question: Which should I use? (Subquestion: should I use one?). The settings would probably only include a few crucial settings and due to the nature or the beast, a few of those would need to be encrypted (password fields or so.) Looking at the problem now I'm thinking it may be far simpler to just hard-code the user names and passwords into the file, but I hate doing that. XML would be fast and easy but it's large and unnecessary while .ini files would be the proper size but I don't know about any facilities for encryption at the field level. Any suggestions? Thanks. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams
Use a .config file - the standard configuration file for .NET applications. Besides including all sorts of runtime configuration, key/value app settings, and what not - it's also an extensible system. See the
IConfigurationSectionHandler
interface in theSystem.Configuration
namespace in the .NET Framework SDK for more information. This is best, IMO, because it keeps an application's configuration in a common place and works with the .NET configuration model, which also includes general settings using the machine.config file. While the documentation I mentioned should mention this, a .config file is either Web.config for ASP.NET or MyApplicationName.exe.config (obviously, replace "MyApplicationName" with the actual exec name) and is in the same directory as the application. This is all default, anyway.Microsoft MVP, Visual C# My Articles
-
Use a .config file - the standard configuration file for .NET applications. Besides including all sorts of runtime configuration, key/value app settings, and what not - it's also an extensible system. See the
IConfigurationSectionHandler
interface in theSystem.Configuration
namespace in the .NET Framework SDK for more information. This is best, IMO, because it keeps an application's configuration in a common place and works with the .NET configuration model, which also includes general settings using the machine.config file. While the documentation I mentioned should mention this, a .config file is either Web.config for ASP.NET or MyApplicationName.exe.config (obviously, replace "MyApplicationName" with the actual exec name) and is in the same directory as the application. This is all default, anyway.Microsoft MVP, Visual C# My Articles
Duh, I should have thought about that. :sigh: For some reason the standard .config completely slipped my mind. Thanks very much Heath. Brian "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." - Douglas Adams