I have tried in 2 different ways
First way: null exception issue
try{
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSNdis_80211_ServiceSetIdentifier");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSNdis_80211_ServiceSetIdentifier instance");
Console.WriteLine("-----------------------------------");
if (queryObj["Ndis80211SsId"] == null)
{
//Console.WriteLine("Ndis80211SsId: {0}",queryObj["Ndis80211SsId"]);
}
else
{
Byte[] arrNdis80211SsId = (Byte[])
(queryObj["Ndis80211SsId"]);
foreach (Byte arrValue in arrNdis80211SsId)
{
//Console.WriteLine("Ndis80211SsId: {0}", arrValue);
}
}
}
}catch(Exception ex){
}
Second way: I'm gating wi-fi but couldnt get the SSID
if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) {
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces()) {
if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 && ni.OperationalStatus== OperationalStatus.Up ) {
Network = "NETWORK ( N/A )";
Wifi = "Wifi (" + ni.Name + ")";
}
}
}
Could you please someone give me clear idea how to get my connected wifi SSID.