如何计算处理时间,例如将文件从1个文件夹复制到另一个文件夹? 打开网络浏览器或计算器。该命令由批处理文件提供给c#,c#首先读取该文件执行它并告诉我每个进程的时间跨度。
答案 0 :(得分:1)
秒表最适合计算经过时间
stopwatch sw = new stopwatch;
sw.Start();
// do something here that you want to measure
sw.Stop();
// Get the elapsed time as a TimeSpan
TimeSpan ts = sw.Elapsed;
// Format and display the TimeSpan
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("That took: {0}", elapsedTime);
答案 1 :(得分:0)