Articles → .NET → Get lock and unlock information of the system using C#

Get lock and unlock information of the system using C#






Steps











Create 2 console applications (one for lock and other for unlock)









Write code to log lock and unlock time in text file






using System;
using System.IO;

namespace Unlock
{
    class Program
    {
        static void Main(string[] args)
        {
            File.AppendAllText(@"C:\test\info.txt", "Unlock time is " + DateTime.Now.ToString() + Environment.NewLine);
        }
    }
}




using System;
using System.IO;

namespace Lock
{
    class Program
    {
        static void Main(string[] args)
        {
            File.AppendAllText(@"C:\test\info.txt", "Lock time is " + DateTime.Now.ToString() + Environment.NewLine);
        }
    }
}



Schedule both the applications using task scheduler









Click to Enlarge




Click to Enlarge








Click to Enlarge








Click to Enlarge












Output





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, March 17, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250