おはよう、私はDateTime
値をアプリの設定に保存しようとしています。アプリ設定の現在の日付時間を保存する
私の設定テーブルでは、私はInstallationDate
とPreviousDate
を示しています。
名|タイプ|適用範囲|バリュー
InstallationDate - のSystem.DateTime - ユーザー -
PreviousDate - のSystem.DateTime - ユーザー -
私は最初の実行時にInstallationDate
を挿入しようとしていますForm_ClosingのPreviousDate
です。
private void frmMainMenu_Load(object sender, EventArgs e)
{
int firstU = Properties.Settings.Default.FirstUse;
int one = 1;
if (firstU == 0)
{
Properties.Settings.Default["FirstUse"] = one;
Properties.Settings.Default.Save();
}
Properties.Settings.Default["InstallationDate"] = DateTime.Now.ToShortDateString();
Properties.Settings.Default.Save();
}
private void frmMainMenu_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default["PreviousDate"] = DateTime.Now.ToShortDateString();
Properties.Settings.Default.Save();
}
しかし、問題は今、その例外
をtrowing「設定プロパティが 『InstallationDate』非互換の型です。」
'System.DateTime'型を使用してプロパティを定義したので、プロパティに' DateTime.Now'を割り当てる必要があります。 –
それ以上、 'DateTime.UtcNow' ... –