views:

71

answers:

4

.................

+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
+2  A: 

I think what you need is Process.StartTime.

erelender
A: 

I think we can also

static DateTime startTime = DateTime.Now;

As someone posted and then deleted

Jader Dias
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
+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