What is wrong with the following statement?
XmlTextWriter writer = new XmlTextWriter(@"D:\project\data\" + System.DateTime.Today + @"\" + System.DateTime.Now + ".xml", null);
When I try the above statement it gives the following error
The given path’s format is not supported.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: The given path’s format is not supported.
Illegal characters aside, what you’re trying to do is impossible for one simple reason: as long as
XmlTextWriterwill create file if it doesn’t exist, it won’t create directory. And that’s what you’re trying to do:You either need to create directories for given day manually:
Or merge date into file name: