private void Form1_Load(object sender, EventArgs e) { string now_date = DateTime.Today.ToString("dd.MM.yyyy"); thisdate.Text = now_date; string path = @"D:\Data\date.txt"; string last_date = ""; using (StreamReader sr = File.OpenText(path)) { string s; while ((s = sr.ReadLine()) != null) { last_date = s; } } /*if (last_date == "") * { * using (StreamWriter sw = File.AppendText(path)) * { * sw.WriteLine(now_date); * } * path= @"D:\Data\"+now_date+".txt"; * File.Create(path); * path= @"D:\Data\Change_"+now_date+".txt"; * File.Create(path); * return; * }*/ if (last_date != now_date) { while (last_date != now_date) { last_date = Work_File.Next_Day(last_date); } using (StreamWriter sw = File.AppendText(path)) { sw.WriteLine(now_date); } } }
private void Next_day_Click(object sender, EventArgs e) { thisdate.Text = Work_File.Next_Day(thisdate.Text); }