I am creating multiple .txt files for my DataGridView and I wanted to add a creation date to them. *****EDIT***** I have changed my code to the following to see if it would output a time stamp:
private void button2_Click(object sender, EventArgs e)
{
DateTime timenow = new DateTime();
DateTime.Now.ToString("yyyyddhh");
Console.WriteLine(timenow.ToString());
string LPath = Path.Combine(path, Path.GetRandomFileName() + ".txt");
using (StreamWriter objWriter = new StreamWriter(LPath, true))
{
string LContent = textName.Text + "," + textVehicle.Text + "," + textDurationH.Text + " " + textDurationM.Text + "," + textFreight.Text + "," + textWeight.Text + "," + textIncome.Text + "," + LPath;
objWriter.Write(LContent);
infoTabelle.Rows.Add(LContent.Split(','));
objWriter.WriteLine();
}
replace();
}
But it just outputs 01.01.0001 00:00:00. What do I have to do? :/
I have tried using various DateTime commands but none have seemed to work for me. Any help is appreciated!
Try
instead of
Then add it to your filename string.