이것은 settings.settings 파일에 새로운 설정을 추가하기 위해 사용하고 있지만 작동하지 않는 코드입니다.Settings.setting 파일에 새 설정 추가하기
System.Configuration.SettingsProperty property = new System.Configuration.SettingsProperty("CustomSetting");
property.DefaultValue = "Default";
property.IsReadOnly = false;
property.PropertyType = typeof(string);
property.Provider = Properties.Settings.Default.Providers["LocalFileSettingsProvider"];
property.Attributes.Add(typeof(System.Configuration.UserScopedSettingAttribute), new System.Configuration.UserScopedSettingAttribute());
Properties.Settings.Default.Properties.Add(property);
// Load settings now.
Properties.Settings.Default.Reload();
// Update the user itnerface.
Properties.Settings.Default["CustomSetting"] = txt_Cipher.Text;
Properties.Settings.Default.Save();
txt_Cipher.Text = string.Empty;
새로운 설정이 설정 파일에 추가되지 않았습니다. 이것은 내가 sumesh의 회신에 따라 노력한 새로운 코드이다.
System.Configuration.SettingsProperty property = new System.Configuration.SettingsProperty("CI");
Properties.Settings.Default["CI"] = txt_Cipher.Text;
Properties.Settings.Default.Save();
Properties.Settings.Default.Reload();
txt_Cipher.Text = string.Empty;
이미 sumesh의 이미지에서 설명한대로 settings.setting 파일에 설정을 만들었습니다.
코드가 예외를 throw합니까? – Sumeshk
아니,하지만 난 그 설정 파일에 변경 사항을 볼 수 없습니다 – wintersolider
일단 그것이 추가되면 CustomSetting가 추가 된 것 같아요 Properties.Settings.Default.Properties.Add (속성); 열쇠가 벌써 존재하는 에러를 슬로우합니다. – Sumeshk