更新时间:2021-11-15 19:52:16
1)您可以使用Guid
作为文件名.
2)您可以保留一个计数器,并为每个保存的文件增加计数器.
1) You can useGuid
as your file name.
2) You can keep a counter and increment that for each file saved.
尝试一下
string FileName=Test+DateTime.Now.ToString().Replace("/", "").Replace(".", "").Replace(":", "").Replace(" ", "")+".txt";
string text = "Test string to write inside the text file";
System.IO.File.WriteAllText(@FileName, text);
使用FileName + HH:MM:SS
连接文件 fileName024658
试试这个
Concatenate file with FileName + HH:MM:SS
fileName024658
Try this
string path = @"D:\";
string fileName = "TestFile" + DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + ".txt";
File.Create(path + fileName);