我需要从代码中删除保存的wifi配置文件,以便再次启用SoftAP。根据ms docs,无法删除配置文件,只能断开连接。这不可能吗?
Ms的wifi文档 https://docs.microsoft.com/zh-cn/uwp/api/windows.devices.wifi.wifiadapter
设备门户API https://docs.microsoft.com/de-ch/windows/mixed-reality/device-portal-api-reference#wifi-management
但是对于删除wifi配置文件,我从API中找不到404。根据上面链接的API文档,该请求应该可以。这是我删除wifi配置文件的代码
// API creds
string username = "Administrator";
string password = "p@ssw0rd
// API request URIs
string apiUri = "http://192.168.1.15:8080/api/wifi/network";
// WiFi details
string wifiInterface = string.Empty;
string wifiProfile = string.Empty;
// WiFi access
WiFiAccessStatus wifiAccess = await WiFiAdapter.RequestAccessAsync();
if (wifiAccess == WiFiAccessStatus.Allowed)
{
// Get WiFi adapter
IReadOnlyList<WiFiAdapter> wifiAdapterResult = await WiFiAdapter.FindAllAdaptersAsync();
WiFiAdapter wifiAdapter = wifiAdapterResult[0];
// Get conn profile / details
ConnectionProfile profile = await wifiAdapter.NetworkAdapter.GetConnectedProfileAsync();
wifiInterface = profile.NetworkAdapter.NetworkAdapterId.ToString();
wifiProfile = profile.ProfileName;
}
// API creds
PasswordCredential credentials = new PasswordCredential("login", username, password);
// HttpClient filter
HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
filter.CookieUsageBehavior = HttpCookieUsageBehavior.NoCookies;
filter.CacheControl.ReadBehavior = HttpCacheReadBehavior.MostRecent;
filter.CacheControl.WriteBehavior = HttpCacheWriteBehavior.NoCache;
filter.ServerCredential = credentials;
要解决此问题,自内部版本17763起,有一种新方法可直接从可用代码中删除WiFi配置文件
bool canDelete = wifiProfile.CanDelete;
if (canDelete)
{
ConnectionProfileDeleteStatus deleteStatus = await wifiProfile.TryDeleteAsync();
}
HUH函数
相关分类