Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Could you please let me know if saving a hashtable as app setting is possible?
I can save a string, a StringCollection as app settings but can't do the same to many other types such as HashTable, object. I coded like this:
Settings.Default.Users = new HashTable();
Settings.Default.Users.Add(username, password);
Settings.Default.Save();
It should save the pair of key and value but it doesn't.
Each time the app starts that Settings.Default.Users becomes null.
Could you please show me how to save it? Please don't lead me to any solution for saving a pair of key and value without using HashTable. I want to use HashTable only.
Thank you very much!
Posted

 
Share this answer
 
Comments
[no name] 1-Nov-11 2:56am    
Thank you! Uhm, it seems not easy to me (a newbie of both csharp and Xml). If possible, could you give me a sample code of saving exactly a HashTable to appSettings and loading it from appSettings?
Thank you very much!
You can use a serializer that understands hashtables like my fastJSON and save the output in your app settings.
 
Share this answer
 
Comments
[no name] 31-Oct-11 23:17pm    
Sorry but this won't work for config files. Implementing a custom section handler is the way to handle this.
[no name] 1-Nov-11 3:01am    
Once again I have received a good solution but too hard for me to understand and practice. If possible, could you give me a sample code demonstrating how to save/load a HashTable to/from appSettings?
Thank you very much!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900