You can try to use WiFiAdapter class, it is UWP API, but we can use it by adding two references.
C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.18362.0\Windows.winmd (you need to change the file type to "All files" in the dialog)
C:\Program Files (x86)\Reference Assembly\Microsoft\Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
Then use the following code.
This is not the final code. My desktop does not support WIFI, so I cannot test it. I just hope to provide some ideas.
public async static Task GetWiFiAdapter()
{
WiFiAdapter firstAdapter = null;
var result = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(WiFiAdapter.GetDeviceSelector());
if (result.Count >= 1)
{
firstAdapter = await WiFiAdapter.FromIdAsync(result[0].Id);
await firstAdapter.ScanAsync();
var wifis = firstAdapter.NetworkReport.AvailableNetworks;
foreach (var item in wifis)
{
Console.WriteLine(item.Ssid);
}
}
else
{
Console.WriteLine("No WIFI adapter available");
}
}
By the way, many desktop motherboards do not support WIFI, especially the old ones. If you are using these motherboards, I think the code will be useless.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.