I am parsing a text file to get settings data for Bluetooth:
This value could be disabled or enabled and marked with an *.
The problem I am having is that its always returning status as "Enabled" regardless if its disabled or not.
Could this be due to that text its reading from has a tab in front of the lines that are indented. How can I correct this to work?
private String GetBluetoothStatus(String FilePath)
{
String[] lines = File.ReadAllLines(FilePath);
int index = 0;
string status = "";
foreach (String s in lines)
{
if (s == "Bluetooth")
{
if (lines[index + 1].StartsWith("*"))
status = "Disabled";
else
status = "Enabled";
return status;
}
index += 1;
}
return status;
}
The text file is below:
BIOSConfig 1.0
;
; Originally created by BIOS Configuration Utility
; Version: 4.0.25.1
; Date="2018/08/06" Time="15:42:35" UTC="-5"
;
; Found 182 settings
;
Power On When AC Detected
*Disabled
Enabled
Power On When Lid is Opened
*Disabled
Enabled
Fast Boot
*Disable
Enable
Bluetooth
Disabled
*Enabled
Wireless Network Device (WLAN)
Disabled
*Enabled
LAN / WLAN Auto Switching
Disabled
*Enabled
fornotforeachloop