コード例 #1
0
        public static async Task <OneDriveInfoResult> GetFolderInFolder(this LiveConnectClient client, string desiredFolderName, string rootFolderId, CancellationToken cancellationToken)
        {
            try
            {
                var result = await client.GetItemsInFolderAsync(rootFolderId, cancellationToken);

                if (!result.IsSuccessful)
                {
                    OneDriveItem empty = new OneDriveFolder();
                    return(new OneDriveInfoResult(false, empty));
                }
                var items         = result.Items;
                var existedFolder = items.FirstOrDefault(item => item.Name.ToUpper() == desiredFolderName.ToUpper() && item.ItemType.HasFlag(OneDriveItemType.Folder));
                if (existedFolder != null)
                {
                    return(new OneDriveInfoResult(true, existedFolder));
                }
                return(await CreateFolderInFolderAsync(client, desiredFolderName, rootFolderId, cancellationToken));
            }
            catch (TaskCanceledException e)
            {
                Debug.WriteLine(e.Message);
                OneDriveItem empty = new OneDriveFolder();
                return(new OneDriveInfoResult(false, empty));
            }
        }
コード例 #2
0
 public static async Task <OneDriveInfoResult> GetItemsInFolderAsync(this LiveConnectClient client, string rootFolderId = ListFileCommandName)
 {
     return(await client.GetItemsInFolderAsync(rootFolderId, CancellationToken.None));
 }