Possible Duplicate:
Displaying the build date
How to know when was Windows started or shutdown?
for my purposes I am writing a C# executable that will calculate the difference in time (minutes) from the time right now and the time the server was last rebooted.
What I am currently doing now is capturing and parsing the output from cmd -> "net stats server" and creating a new DateTime
object then comparing that with DateTime.Now
with a TimeSpan
object.
Is there a cleaner way to do this without the use of 3rd party downloads? I am scared that not all date formats from "net stats server" are in the format that I will expect.
**edit my bad, this is a duplicate, but for what it is worth my solution was using this:
float ticks = System.Environment.TickCount;
Console.WriteLine("Time Difference (minutes): " + ticks / 1000 / 60);
Console.WriteLine("Time Difference (hours): " + ticks / 1000 / 60 / 60);
Console.WriteLine("Time Difference (days): " + ticks / 1000 / 60 / 60 / 24);