المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Create txt file with date as name



C# Programming
08-27-2009, 06:14 PM
I am very new to C#, and i just want to create a .txt file with the current date and time as the filename.

Here is the code i've put together from bits and pieces on the net, and it isnt working

string date = DateTime.Now.ToString("yyyyMMdd_hhmmss");
TextWriter tw = new StreamWriter("{0}.txt", date);

I have also tried

TextWriter tw = new StreamWriter(DateTime.Now.ToString("yyyyMMdd_hhmmss.txt"));

It creates the filename i want, but with the .pxp extension instead of the .txt

Any help would be greatly appreciated http://www.barakasoft.com/script/Forums/Images/smiley_smile.gif