您的位置:首页 > 运维架构

Properties.Setting.Default保存配置信息的方法

2012-04-06 13:32 387 查看
Properties.Setting.Default保存配置信息的方法

1.定义---将保存信息在Properties.Setting.Designer.cs中定义

[global::System.Configuration.UserScopedSettingAttribute()]

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

[global::System.Configuration.DefaultSettingValueAttribute("30.93")]

public double MainMapLat

{

get

{

return ((double)(this["MainMapLat"]));

}

set

{

this["MainMapLat"] = value;

}

}

[global::System.Configuration.UserScopedSettingAttribute()]

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]

[global::System.Configuration.DefaultSettingValueAttribute("115.10")]

public double MainMapLng

{

get

{

return ((double)(this["MainMapLng"]));

}

set

{

this["MainMapLng"] = value;

}

}

2.保存---windform窗体关闭时将当前Lat,Lng保存

Properties.Settings.Default.MainMapLat = MainMap.Position.Lat;

Properties.Settings.Default.MainMapLng = MainMap.Position.Lng;

Properties.Settings.Default.Save();

3.获取-- cs文件直接使用

double theCenterLat = Properties.Settings.Default.MainMapLat;

double theCenterLng = Properties.Settings.Default.MainMapLng;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: