在Properties.Settings中可以把一个变量Scope设成Application的或者是User,我是向读取Settings中的初始值并且再保存进去,Application的不能保存,而User的可以,但却没保存在我的那个Settings中,而是保存在了我的本地用户的C:\Documents and Settings\lile\Local Settings\Application Data\中了,我想问问各位高手能不能设置保存的目录,或是直接能保存在Properties.Settings中啊?
...能不能设置保存的目录then how do you know other users' folder structure?
不妨重新读取该xml文件 然后进行写入操作。
譬如 你创建一个scope为user的变量CONST_USERNAME的话,初始值是"default" 你想把它改成"changed" XmlDocument propertyXml = new XmlDocument();
propertyXml.Load(Application.ExecutablePath + ".config"); //读入[应用程序名.exe.config]文件XmlNode settingNodes = propertyXml.SelectSingleNode
("/configuration/userSettings/WindowsApplication1.Properties.Settings");//此处根据你的xml文件,节点名称会有所不同for (int i = 0; i < settingNodes.ChildNodes.Count; i++)
{
if (settingNodes.ChildNodes[i].Attributes["name"].Value == "CONST_USERNAME")
{
settingNodes.ChildNodes[i].ChildNodes[0].InnerText = "changed";//修改设置的值
break;
}
}propertyXml.Save(Application.ExecutablePath + ".config");//保存[应用程序名.exe.config]文件