我正在构建一个简单的VS2008插件。存储自定义运行时设置的最佳实践是什么?您将app.config存储在何处,以及如何从外接程序访问它?
发布于 2008-12-06 03:31:42
尝试使用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();
}
}
}https://stackoverflow.com/questions/344024
复制相似问题