LoginSignup
0
0

More than 5 years have passed since last update.

ApplicationSettingsBase.Properties と PropertyValues

Posted at

ApplicationSettingsBase.Properties と PropertyValues

格納されている値が、似ているようで異なるので調べた。
ApplicationSettingsBase は、C# の Windows Form アプリケーションであれば Properties.Settings.Default として扱うインスタンスの基底クラス。

Properties

ユーザ設定が存在しない場合のデフォルト値
Visual Studio を使うなら、プロジェクトのプロパティで [設定] タブのエディタで編集した値がデフォルト値で、これを操作できる。

// 次でアクセスできる
Properties.Settings.Default.Properties[設定名]?.DefaultValue

PropertyValues

ユーザ設定値
Visual Studio でビルドすると実行可能ファイルと同じフォルダに出力され、実行環境に配布する 実行ファイル名.exe.config に設定した値が格納され、これを操作できる。

配布する config ファイルは XML 形式なので、配布後に編集することも可能だが、アプリケーションが Properties.Settings.Defalut の仕組みを利用する限りは、設計時に定義する Settings.Designer.cs のプロパティしか読み込まれない。

// 次でアクセスできる
Properties.Settings.Default.PropertyValues[設定名]?.PropertyValue

確認した環境

  • 日本語 Windows 10 Home 64 ビット
  • Visual Studio Community 2015 Update 3
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0