code_junkie

How to use app.config with Visual Studio add-in?

Nov 12th, 2011
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAssembly())
  2. {
  3. using (StreamWriter stream = new StreamWriter(new IsolatedStorageFileStream("YourConfig.xml", FileMode.Create, file)))
  4. {
  5. stream.Write(YourXmlDocOfConfiguration);
  6. }
  7. stream.Flush();
  8. stream.Close();
  9. }
  10.  
  11. string yourConfigXmlString;
  12. using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAssembly())
  13. {
  14. string[] files = file.GetFileNames("YourConfig.Xml");
  15. if (files.Length > 0 && files[0] == "YourConfig.xml"))
  16. {
  17. using (StreamReader stream = new StreamReader(new IsolatedStorageFileStream("YourConfig.xml", FileMode.Open, file)))
  18. {
  19. yourConfigXmlString = stream.ReadToEnd();
  20. }
  21. }
  22. }
Add Comment
Please, Sign In to add comment