How to sort AppSettings without manually missing any keys or important information.
You can modify the code to write the keys in the form of . Then copy and paste the output to your actual config file. You have all the keys in sorted order.
Code Snippet
- private void WriteAppSettingsToFile(string filename)
- {
- List<string> lstConfigKeys = new List<string>();
- foreach (string appKey in ConfigurationManager.AppSettings.AllKeys)
- {
- lstConfigKeys.Add(appKey);
- }
- lstConfigKeys.Sort();
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\" + filename + ".txt"))
- {
- foreach (string key in lstConfigKeys)
- {
- file.WriteLine(string.Format("'{0}', -- {1}", key, ConfigurationManager.AppSettings.Get(key)));
- }
- }
- }
You can modify the code to write the keys in the form of
No comments:
Post a Comment