Articles → .NET → Check the battery life percentage of laptop using C#

Check the battery life percentage of laptop using C#






Code


using System;
using System.Globalization;
using System.Windows.Forms;

namespace BatteryLife {
	class Program {
		static void Main(string[] args) {
			string batteryLifePercentage = SystemInformation.PowerStatus.BatteryLifePercent.ToString("P", CultureInfo.InvariantCulture);
			Console.WriteLine("battery life remaining status : " + batteryLifePercentage);
			Console.Read();
		}
	}
}



Output



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, March 01, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250