创建文件时,如何把当前时间设为文件名?
private void SaveFile()
{
string fileName = DateTime.Now.ToString();
string path =
using (StreamWriter sw = File.CreateText(path))
try
{
sw.Write(DateTime.Now);
sw.Write( " " + textBox1.Text + " ");
sw.WriteLine( " " + textBox2.Text + " ");
}
}
------解决方案--------------------无所谓......
可以直接写成
DateTime.Now.ToString( "yyyyMMddHHmmssffffff.txt ");
------解决方案--------------------把年月日时分秒PING成一个字符串