我正在使用c#在VS2010中创建一个项目,我有一个字符串值,当前我正在将其写入项目的Properties.settings。
当我关闭机器并重新启动时,我记下了这个值看起来好像没有保存?
另一种可能性是,当我将我的代码提交给SVN时,可能那个值还没有写出来。
所以有人能帮我确认一下吗,
当我向Properties.Settings写入字符串值时,这只是暂时的吗?我会不会最终不得不把它写到一个文本文件或其他文件中呢?
请提供有关这方面的信息,我们将非常感谢。
提前感谢;)
发布于 2011-03-27 02:54:38
这些是应用程序范围还是用户范围?不能在运行时更改应用程序范围的设置。
您是否在调用Settings.Save()来保存设置?
有关更多信息,请参阅此msdn文章:Using Settings in C#
发布于 2011-03-27 03:18:55
d:\Users\Robo\AppData\Local\DataCrea\WorkShifts.exe_Url_4ssvgihryk04nltgkxam4dh4bdhymcqa\0.9.28.0\user.config
True我不确定下面的事情是否会影响你的问题,但是添加布尔属性CallUpgrade = Properties.Settings.Default.Save();
//升级属性,如果( Settings.Default.CallUpgrade ) { Settings.Default.Upgrade();Settings.Default.CallUpgrade= false;Settings.Default.Save();}增加了版本
..。Upgrade()将确保从以前的版本正确迁移设置。
发布于 2011-03-27 03:31:21
如果调用Properties.Settings.Default.Save();,它们将被永久保存
下面是我用来记住窗口位置和大小的一些代码:
<Window x:Class="my_namespace.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:my_namespace"
Closing="save_position"
Height="{Binding Source={x:Static local:Properties.Settings.Default}, Path=height, Mode=TwoWay}"
Width="{Binding Source={x:Static local:Properties.Settings.Default}, Path=width, Mode=TwoWay}"
Top="{Binding Source={x:Static local:Properties.Settings.Default}, Path=top, Mode=TwoWay}"
Left="{Binding Source={x:Static local:Properties.Settings.Default}, Path=left, Mode=TwoWay}">在后面的代码中如下所示:
private void save_position(object sender, CancelEventArgs e)
{
Properties.Settings.Default.Save();
}https://stackoverflow.com/questions/5444443
复制相似问题