Backup

        /*
        private void writeLog()
        {
            string t = DateTime.Now.ToString("yyyyMMdd");
            if (File.Exists(CurrentPath + "\log\" + t + ".txt"))
            {
                StreamWriter nw = new StreamWriter(CurrentPath + "\log\" + t + ".txt", true, System.Text.Encoding.UTF8);
                for (int i = 0; i < listBox2.Items.Count; i++)
                {
                    nw.WriteLine(listBox2.Items[i]);
                }
                nw.Close();
            }
            else
            {
                StreamWriter sw = new StreamWriter(CurrentPath + "\log\" + t + ".txt", false, System.Text.Encoding.UTF8);
                for (int i = 0; i < listBox2.Items.Count; i++)
                {
                    sw.WriteLine(listBox2.Items[i]);
                }
                sw.Close();
            }
        }
        */
原文地址:https://www.cnblogs.com/EthanSun/p/3205312.html