아래 동작은 모바일 핫스팟에 적용이 안됨
netsh wlan set hostednetwork mode=allow ssid=YOUR_NETWORK_NAME key=YOUR_PASSWORD
Windows Runtime(WinRT)를 적용해야 함
적용법: Netcore3.0~ 또는 Net6.0으로 Nuget Package Microsoft.Windows.SDK.Contracts 적용
소스:
public class MobileHotSpot
{
public static async void Start()
{
var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
var tethering = NetworkOperatorTetheringManager.CreateFromConnectionProfile(connectionprofile);
if (tethering.TetheringOperationalState == TetheringOperationalState.On)
{
Console.WriteLine("Mobile hotspot is enabled");
return;
}
Console.WriteLine("Start mobile hotspot");
await tethering.StartTetheringAsync();
}
public static async void Stop()
{
var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
var tethering = NetworkOperatorTetheringManager.CreateFromConnectionProfile(connectionprofile);
if (tethering.TetheringOperationalState == TetheringOperationalState.Off)
{
Console.WriteLine("Mobile hotspot is disabled");
return;
}
Console.WriteLine("Stop mobile hotspot");
await tethering.StopTetheringAsync();
}
}
'C#' 카테고리의 다른 글
Dictionary Pair 실행 시간 측정 (0) | 2022.08.24 |
---|---|
[수정필요] NetCoreServer OnReceived 길이 읽기 저장용 샘플 (0) | 2022.05.01 |
PathHelper - 파일 생성 및 리드할 때 디렉토리 확인용 (0) | 2022.05.01 |
JsonHelper - Newtonsoft 이용 (0) | 2022.05.01 |
Sliding Stream (0) | 2022.05.01 |