I am trying to write all my data to a text file and it is working unless I put DateTime
in the file name.
The current code looks like this:
string time = DateTime.Now.ToString("d");
string name = "MyName";
File.WriteAllText(time+name+"test.txt","HelloWorld");
I am getting this exception:
An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
But as far as I know, the File.WriteAllText()
method should create a new file or overwrite already existed file.
Any suggestions?