using System;
using System.Windows.Forms;
using System.Configuration;
using System.IO;
namespace WF
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_FormClosed(object sender,
FormClosedEventArgs e)
{
System.Configuration.Configuration conf =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
conf.AppSettings.Settings["LastTime"].Value =
DateTime.Now.ToString("HH:mm:ss");
conf.Save(ConfigurationSaveMode.Modified);
try
{
//Debug Mode時回寫app.config
if (System.Diagnostics.Debugger.IsAttached)
File.Copy(conf.FilePath,
"..\\..\\app.config", true);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
System.Configuration.Configuration conf =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
this.Text = "LastTime => " +
conf.AppSettings.Settings["LastTime"].Value;
}
}
}