How to get the DateTime when the current process started?
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);
}
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With