我正在为我的 DataGridView 创建多个 .txt 文件,我想为它们添加一个创建日期。*****编辑***** 我已将代码更改为以下内容,以查看它是否会输出时间戳:
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();
}
但它只输出 01.01.0001 00:00:00。我需要做什么?:/
我尝试过使用各种 DateTime 命令,但似乎没有一个对我有用。任何帮助表示赞赏!