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