1
我正在构建一个简单的VS2008加载项。存储自定义运行时设置的最佳做法是什么?你在哪里存储app.config,以及如何从加载项访问它?如何在Visual Studio加载项中使用app.config?
我正在构建一个简单的VS2008加载项。存储自定义运行时设置的最佳做法是什么?你在哪里存储app.config,以及如何从加载项访问它?如何在Visual Studio加载项中使用app.config?
尝试像这样用System.IO.IsolatedStorageFile(没有测试样本代码..它只是显示的想法)
写作
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAssembly())
{
using (StreamWriter stream = new StreamWriter(new IsolatedStorageFileStream("YourConfig.xml", FileMode.Create, file)))
{
stream.Write(YourXmlDocOfConfiguration);
}
stream.Flush();
stream.Close();
}
阅读
string yourConfigXmlString;
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForAssembly())
{
string[] files = file.GetFileNames("YourConfig.Xml");
if (files.Length > 0 && files[0] == "YourConfig.xml"))
{
using (StreamReader stream = new StreamReader(new IsolatedStorageFileStream("YourConfig.xml", FileMode.Open, file)))
{
yourConfigXmlString = stream.ReadToEnd();
}
}
}