问题
In one of my c# application, i have to write directories path inside config file as following
Main Folder = Sites
Sub Folders = 400, 500, 600, and so on
For each subfolders = Inst, Prof
Inside Inst and Prof , we have multiple files.
Inside my program, i have to fetch all sites (400, 500 etc) and then i have to write loop for all sites for both folders (Inst and Prof) one by one, once DONE then go for next site and so on
What is best way to write above folder structure in App.config file?
回答1:
You should check out Jon Rista's three-part series on .NET 2.0 configuration up on CodeProject.
- Unraveling the mysteries of .NET 2.0 configuration
- Decoding the mysteries of .NET 2.0 configuration
- Cracking the mysteries of .NET 2.0 configuration
Highly recommended, well written and extremely helpful! This will give you a thorough understanding of the .NET configuration system.
To design your own custom section, there's also a handy tool (Visual Studio add-in) called Configuration Section Designer that will make it very easy and simple to create your own custom section and have it build up all the necessary code to handle that custom section.
回答2:
There is an easy way to create custom configure . custom-configuration-sections-in-3-easy-steps
来源:https://stackoverflow.com/questions/8642247/how-can-we-write-our-own-configuration-in-app-config