[問]VS2005,C#winform程序,代碼修改app.config的結(jié)果保存到哪里了?
通過Properties.Settings用代碼形式讀寫app.config文件,其中Properties.Settings變量的范圍"scope"都設(shè)置為用戶"user"(注:如果改為"Application",編譯時(shí)系統(tǒng)提示其為只讀屬性),讀寫都正常,并且重新打開exe文件時(shí),上次輸入的值仍然存在,但是手動(dòng)打開"test.exe.config",所有的設(shè)置變量值均為空,寫入的值都保存到什么地方去了呢?臨時(shí)文件?我用360安全衛(wèi)士清除臨時(shí)文件后在此打開exe文件,上次輸入的值依然存在。有誰知道這是怎么回事?
示例代碼:
private void button1_Click(object sender, EventArgs e)
{
//讀操作,將讀到的值送textBox1顯示
Properties.Settings config = Properties.Settings.Default;
textBox1.Text = config.myvar;
}
private void button2_Click(object sender, EventArgs e)
{
//寫操作,將textBox2里的值寫入myvar
Properties.Settings config = Properties.Settings.Default;
config.myvar = textBox2.Text;
config.Save();
}
通過Properties.Settings用代碼形式讀寫app.config文件,其中Properties.Settings變量的范圍"scope"都設(shè)置為用戶"user"(注:如果改為"Application",編譯時(shí)系統(tǒng)提示其為只讀屬性),讀寫都正常,并且重新打開exe文件時(shí),上次輸入的值仍然存在,但是手動(dòng)打開"test.exe.config",所有的設(shè)置變量值均為空,寫入的值都保存到什么地方去了呢?臨時(shí)文件?我用360安全衛(wèi)士清除臨時(shí)文件后在此打開exe文件,上次輸入的值依然存在。有誰知道這是怎么回事?
示例代碼:
private void button1_Click(object sender, EventArgs e)
{
//讀操作,將讀到的值送textBox1顯示
Properties.Settings config = Properties.Settings.Default;
textBox1.Text = config.myvar;
}
private void button2_Click(object sender, EventArgs e)
{
//寫操作,將textBox2里的值寫入myvar
Properties.Settings config = Properties.Settings.Default;
config.myvar = textBox2.Text;
config.Save();
}