csharp Get System Uptime

TimeSpan ts = TimeSpan.FromMilliseconds(Environment.TickCount);
int uptimeMinutes = ts.Minutes;
int uptimeHours = ts.Hours;
int uptimeDays = ts.Days;

Application["Uptime"] = String.Format("Uptime: {0} days, {1} hours, {2} minutes", uptimeDays, uptimeHours, uptimeMinutes);
Gets time since the system was started.

Updated: Friday 8th April 2011, 07:57am

There are 0 comments

Leave a comment of your own

Comments are currently closed.