You can use System.Diagnostics.PerformanceCounter class to retrieve the system uptime (boot time) in seconds. Here is the code:
main.cs441 chars13 linesThe NextValue() method retrieves the current value of the performance counter. The PerformanceCounterType.PerformanceCounterTypeSystemUpTime.GetSystemUptime() method is used to get the initial boot time value to subtract from the current system time. The returned value is the system uptime in seconds.
gistlibby LogSnag