Is there a way to know for how much time the system has not been rebooted?

  • Thread starter Thread starter ThunderMusic
  • Start date Start date
T

ThunderMusic

Hi,
When I open my MIRC, it tells me "x days xx hours xx minutes xx seconds
have passed since your system last rebooted". I wanted to know if there is
some way to know this information within .NET.

Thanks

ThunderMusic
 
TM,

System.Diagnostics.PerformanceCounter pc = new
System.Diagnostics.PerformanceCounter("System", "System Up Time");
pc.NextValue();
TimeSpan span = System.TimeSpan.FromSeconds(pc.NextValue());
Console.WriteLine("Uptime = " + span.ToString());

Enjoy,

- William Bloodworth
 
TickCount Property of the Environment type returns the number of
milliseconds elapsed since the system started.

HTH, Metallikanz!
 
Back
Top