デフォルトの user.config 設定ファイルを使用しようとしていますが、デフォルトの場所以外の場所に保存したいと考えています。ファイルを読み書きしようとしても何もしませんが、エラーはスローされません。また、フォルダーとファイルを手動で作成する必要がありました。誰かがここで私が間違っている場所を教えてもらえますか?
location = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\MyProgram\" + Environment.UserName + ".config";
AppDomain.CurrentDomain.SetData("USER_CONFIG_FILE", location);
textBox1.Text = Settings.Default["Text1"].ToString();
label1.Text = Settings.Default["Text1"].ToString();
}
private void button1_Click(object sender, EventArgs e)
{
Settings.Default["Text1"] = textBox1.Text;
Settings.Default.Save();
label1.Text = Settings.Default["Text1"].ToString();
}