我正在尝试对OneDrive Windows客户端执行非常基本的连接检查。
我一直在玩Live SDK,但这通常会让我走上授权用户和建立会话的道路。我对任何上传/下载功能都不感兴趣,也不需要在我的应用程序中集成OneDrive。这让我觉得SDK不适合下去。
有什么想法吗?
答案 0 :(得分:0)
如果您只是在寻找连接检查,您可能想要.Net中提供的网络连接配置文件呼叫,例如:
ConnectionProfile internetConnectionProfile = NetworkInformation.GetInternetConnectionProfile();
if (internetConnectionProfile == null)
{
Debug.WriteLine("CanPerformODOperations: not connected to Internet");
return OneDriveStatus.noInternetConnection;
}
if (App.Settings.UnrestrictedDownloads)
{
Debug.WriteLine("CanPerformODOperations: app settings set to unrestricted downloads");
return OneDriveStatus.OK;
}
if (internetConnectionProfile.GetNetworkConnectivityLevel() != NetworkConnectivityLevel.InternetAccess)
{
Debug.WriteLine("CanPerformODOperations: not got Internet access");
return OneDriveStatus.noUnrestrictedNetwork;
}
ConnectionCost cost = internetConnectionProfile.GetConnectionCost();
if (cost == null || cost.NetworkCostType == NetworkCostType.Unrestricted)
{
Debug.WriteLine("CanPerformODOperations: cost is null or unrestricted");
return OneDriveStatus.OK;
}
Debug.WriteLine("CanPerformODOperations: not got an unrestricted network");
return OneDriveStatus.noUnrestrictedNetwork;
我将OneDriveStatus定义为:
public enum OneDriveStatus { unknownProblem, noInternetConnection, noUnrestrictedNetwork, OK };
如果我从这些电话中获得OneDriveStatus.OK,我只会尝试登录。