private async Task NavigateBackAsync()
        {
            if (_graphCurrentFolder != null)
            {
                OneDriveStorageFolder currentFolder = null;
                SampleController.Current.DisplayWaitRing = true;
                try
                {
                    if (!string.IsNullOrEmpty(_graphCurrentFolder.Path))
                    {
                        currentFolder = await _graphRootFolder.GetFolderAsync(_graphCurrentFolder.Path);
                    }
                    else
                    {
                        currentFolder = _graphRootFolder;
                    }

                    OneDriveItemsList.ItemsSource = currentFolder.GetItemsAsync(10);
                    _graphCurrentFolder           = currentFolder;
                }
                catch (ServiceException ex)
                {
                    await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex);
                }
                finally
                {
                    SampleController.Current.DisplayWaitRing = false;
                }
            }
        }
        private async Task NavigateBackAsync()
        {
            if (_currentFolder != null)
            {
                OneDriveStorageFolder currentFolder = null;
                progressRing.IsActive = true;
                try
                {
                    if (!string.IsNullOrEmpty(_currentFolder.Path))
                    {
                        currentFolder = await _rootFolder.GetFolderAsync(_currentFolder.Path);
                    }
                    else
                    {
                        currentFolder = _rootFolder;
                    }

                    LstFolder.ItemsSource = await currentFolder.GetFoldersAsync(100);

                    _currentFolder = currentFolder;
                }
                catch (ServiceException ex)
                {
                    await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex);
                }
                finally
                {
                    progressRing.IsActive = false;
                }
            }
        }
        public static async Task <OneDriveStorageFile> GetOneDriveFilesAsync(string fileName)
        {
            if (rootFolder is null)
            {
                if (!await LogintoOnedriveAsync())
                {
                    throw new InvalidOperationException("Failed to log in");
                }
                if (rootFolder is null)
                {
                    var root = await OneDriveService.Instance.AppRootFolderAsync();

                    Interlocked.CompareExchange(ref rootFolder, root, null);
                }
            }
            fileName = fileName.Split(@"\OneDrive\", 2).Last();
            var folderName = SysPath.GetDirectoryName(fileName);
            var sFileName  = SysPath.GetFileName(fileName);

            if (folderName.IsNullorEmpty())
            {
                return(await rootFolder.GetFileAsync(fileName));
            }

            var file = default(OneDriveStorageFile);

            // copy to local to avoid changes by other threads
            var currentCache = cache;

            if (currentCache != null && folderName == currentCache.FolderName)
            {
                file = currentCache.Files.Find(f => f.Name == sFileName);
            }
            if (file != null)
            {
                return(file);
            }

            // cache miss
            var folder = await rootFolder.GetFolderAsync(folderName);

            var files = await folder.GetFilesAsync(10000);

            file  = files.Find(f => f.Name == sFileName);
            cache = new CacheData
            {
                Files      = files,
                Folder     = folder,
                FolderName = folderName,
            };
            if (file != null)
            {
                return(file);
            }

            // slow route: first 10000 files missed
            return(await folder.GetFileAsync(sFileName));
        }
        private async Task NavigateToFolderAsync(Toolkit.Uwp.Services.OneDrive.OneDriveStorageItem item)
        {
            if (item.IsFolder())
            {
                Shell.Current.DisplayWaitRing = true;
                try
                {
                    var currentFolder = await _currentFolder.GetFolderAsync(item.Name);

                    OneDriveItemsList.ItemsSource = currentFolder.GetItemsAsync();
                    _currentFolder = currentFolder;
                }
                catch (ServiceException ex)
                {
                    await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex);
                }
                finally
                {
                    Shell.Current.DisplayWaitRing = false;
                }
            }
        }
        private async Task NavigateToFolderAsync(OneDriveStorageItem item)
        {
            if (item.IsFolder())
            {
                SampleController.Current.DisplayWaitRing = true;
                try
                {
                    var currentFolder = await _graphCurrentFolder.GetFolderAsync(item.Name);

                    OneDriveItemsList.ItemsSource = await currentFolder.GetItemsAsync(20);

                    _graphCurrentFolder = currentFolder;
                }
                catch (ServiceException ex)
                {
                    await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex);
                }
                finally
                {
                    SampleController.Current.DisplayWaitRing = false;
                }
            }
        }
        private async Task NavigateToFolderAsync(OneDriveStorageItem item)
        {
            progressRing.IsActive = true;
            try
            {
                var currentFolder = await _graphCurrentFolder.GetFolderAsync(item.Name);

                var items = await currentFolder.GetFoldersAsync(100);

                if (items.Count > 0)
                {
                    LstFolder.ItemsSource = items;
                    _graphCurrentFolder   = currentFolder;
                }
            }
            catch (ServiceException ex)
            {
                await OneDriveSampleHelpers.DisplayOneDriveServiceExceptionAsync(ex);
            }
            finally
            {
                progressRing.IsActive = false;
            }
        }