"Rene Ren" <re**@vip.139sc .com> wrote in
news:#K******** ******@TK2MSFTN GP11.phx.gbl:
I can using Environment.Tic kCount property to get the time
elapsed since the system started. but this property using A
32-bit signed integer type, so it's can't count the time more
than 24.9 days. How can I do ?
A performance counter can give you that information:
using System;
using System.Diagnost ics;
namespace Example
{
public class ExampleClass
{
public static void Main()
{
PerformanceCoun ter pc = new PerformanceCoun ter("System", "System Up Time");
// The first call to NextValue() returns 0.0.
pc.NextValue();
// The second call to NextValue() returns the number of
// seconds that have elapsed since the machine was turned on.
TimeSpan ts = TimeSpan.FromSe conds((long) pc.NextValue()) ;
Console.WriteLi ne("System Up Time: {0} days, {1} hours, {2} minutes, {3} seconds", ts.Days, ts.Hours, ts.Minutes, ts.Seconds);
}
}
}
--
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/