.................
+13
A:
The StartTime
property on the Process
type is returning that value:
Process.GetCurrentProcess().StartTime
This can of course be used to pick up the start time of other processes as well:
Process p = Process.GetProcessesByName("Notepad").FirstOrDefault();
if (p != null)
{
Console.WriteLine(p.StartTime);
}
Fredrik Mörk
2010-01-07 15:20:07
A:
I think we can also
static DateTime startTime = DateTime.Now;
As someone posted and then deleted
Jader Dias
2010-01-07 15:22:09
Very, very fragile. You have no guarantees that will run before any other static initializers, so that can actually be *a lot* different from the real value. Also, static initializers are run only when its containing type is referenced, which is another source of problems.
Martinho Fernandes
2010-01-07 15:25:01
+1
A:
You will need the Process Class found in System.Diagnostics.
using System.Diagnostics;
then a function like this will suffice.
public DateTime GetStartTime()
{
return Process.GetCurrentProcess().StartTime;
}
Skintkingle
2010-01-07 15:23:16