예제 #1
0
        private void Window_Closed(object sender, EventArgs e)
        {
            XmlConfigUtil util = new XmlConfigUtil("config.xml");

            util.Write(BattleNetPath, "BattleNetPath");
            util.Write(HearthbuddyPath, "HearthbuddyPath");
            util.Write(BNHSInterval.ToString(), "BNHSInterval");
            util.Write(HSHBInterval.ToString(), "HSHBInterval");
            util.Write(CheckInterval.ToString(), "CheckInterval");

            util.Write(StartTime.Hour.ToString(), "StartTime");
            util.Write(EndTime.Hour.ToString(), "EndTime");

            string logDirectory = Path.Combine(this.BaseDirectory, "Logs");

            if (!Directory.Exists(logDirectory)) //防止目录不存在报错
            {
                Directory.CreateDirectory(logDirectory);
            }
            string logPath = Path.Combine(logDirectory, $"HearthbuddyHelper_{DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")}.log");

            using (StreamWriter sw = new StreamWriter(logPath, true, System.Text.Encoding.UTF8))
            {
                sw.Write(LogTextBox.Text);
            }

            Environment.Exit(0);
        }