Table of Contents

Class WifiAdapter

Namespace
System.Device.Wifi
Assembly
System.Device.Wifi.dll

Provides a means to scan for nearby Wifi access points, enumerate those that are found, and connect to an access point.

public sealed class WifiAdapter : IDisposable
Inheritance
WifiAdapter
Implements
Inherited Members
Extension Methods

Properties

NetworkInterface

Gets the network interface number associatted with this Wifi adapter

public int NetworkInterface { get; }

Property Value

int

NetworkReport

Gets a list of available networks populated by the last Wifi scan on this WifiNetworkAdapter.

public WifiNetworkReport NetworkReport { get; }

Property Value

WifiNetworkReport

Methods

Connect(WifiAvailableNetwork, WifiReconnectionKind, string)

Connect this Wifi device to the specified network, with the specified pass-phrase and reconnection policy.

public WifiConnectionResult Connect(WifiAvailableNetwork availableNetwork, WifiReconnectionKind reconnectionKind, string passwordCredential)

Parameters

availableNetwork WifiAvailableNetwork

Describes the Wifi network to be connected.

reconnectionKind WifiReconnectionKind

Specifies how to reconnect if the connection is lost.

passwordCredential string

The pass-phrase to be used to connect to the access point.

Returns

WifiConnectionResult

On successful conclusion of the operation, returns an object that describes the result of the connect operation.

Connect(string, WifiReconnectionKind, string)

Connect this Wifi device to the specified network (using SSID string), with the specified pass-phrase and reconnection policy.

public WifiConnectionResult Connect(string ssid, WifiReconnectionKind reconnectionKind, string passwordCredential)

Parameters

ssid string

Describes the Wifi network to be connected.

reconnectionKind WifiReconnectionKind

Specifies how to reconnect if the connection is lost.

passwordCredential string

The pass-phrase to be used to connect to the access point.

Returns

WifiConnectionResult

On successful conclusion of the operation, returns an object that describes the result of the connect operation.

Disconnect()

Disconnects any active Wifi connection through this adapter.

public void Disconnect()

Dispose()

Dispose WifiAdapter

public void Dispose()

Finalize()

protected override void Finalize()

FindAllAdapters()

A static method that enumerates all the Wifi adapters in the system.

public static WifiAdapter[] FindAllAdapters()

Returns

WifiAdapter[]

On successful completion, returns an array of WifiAdapter objects

ScanAsync()

Directs this adapter to initiate an asynchronous network scan.

public void ScanAsync()

Remarks

On successful completion, returns a list of Wi-Fi networks scanned by this adapter signaled by the AvailableNetworksChanged event. Use NetworkReport to retrieve the list of available Wi-Fi networks.

Exceptions

InvalidOperationException

If the Wi-Fi interface hasn't been started.

TimeoutException

If a timeout occurred when trying to initiate a scan operation.

SetDeviceName(string)

Sets the device name advertised by this Wi-Fi adapter when connecting to a network.

public void SetDeviceName(string deviceName)

Parameters

deviceName string

The device name to assign to this adapter.

Remarks

The device name is sent to the access point during connection and may appear in the router’s client list or DHCP lease table.
This method must be called before initiating a connection to take effect.

Exceptions

ArgumentException

If deviceName is null, empty or the length over 32 characters.

NotSupportedException

Thrown when the current firmware was built without Wi-Fi and setting the device name is not supported on this platform.

NotImplementedException

Thrown on platforms where setting the device name is not yet implemented.

InvalidOperationException

Thrown when the underlying Wi-Fi stack rejects to specify device name.

Events

AvailableNetworksChanged

Event raised when a scan completes on this Wifi adapter.

public event AvailableNetworksChangedEventHandler AvailableNetworksChanged

Event Type

AvailableNetworksChangedEventHandler