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


Picture showing the percentage charging of the laptop battery
Click to Enlarge


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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250