效果如图
代码如下:
string year = DateTime.Now.Year.ToString() + "年";
string month = DateTime.Now.Month.ToString() + "月";
string day = DateTime.Now.Day.ToString() + "日";
string file_path = "e:\\" + year + "\\" + month + "\\" + day ;
if (!Directory.Exists(file_path)) //如果“日期”的文件不存在
{
Directory.CreateDirectory(file_path); //创建一个“日期”的文件夹
}
string time = DateTime.Now.ToString("HH-mm-ss");
string file_path1 = "e:\\" + year + "\\" + month + "\\" + day + ".txt";
using (StreamWriter sw = new StreamWriter(file_path1, true, UnicodeEncoding.GetEncoding("GB2312")))
{
string str = txtRev.Text;
sw.Write(str);
sw.Close();
}