コード例 #1
0
        private async Task <List <StorageFile> > retrievegoalImageDataFromCloud(OneDriveStorageFolder imageFolder, StorageFolder localFolder)
        {
            var localImageFolder = await localFolder.GetFolderAsync("ImageFolder");

            List <StorageFile> newGoalImageData = new List <StorageFile>();

            List <OneDriveStorageFile> cloudImageFiles = await imageFolder.GetFilesAsync();



            foreach (var cloudImageFile in cloudImageFiles)
            {
                using (var cloudFileStream = await cloudImageFile.OpenAsync())
                {
                    byte[] buffer      = new byte[cloudFileStream.Size];
                    var    localBuffer = await cloudFileStream.ReadAsync(buffer.AsBuffer(), (uint)cloudFileStream.Size, InputStreamOptions.ReadAhead);

                    var newGoalImageFile = await localImageFolder.CreateFileAsync($"{cloudImageFile.Name}", CreationCollisionOption.ReplaceExisting);

                    using (var localStream = await newGoalImageFile.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        await localStream.WriteAsync(localBuffer);

                        await localStream.FlushAsync();
                    }
                    newGoalImageData.Add(newGoalImageFile);
                }
            }
            return(newGoalImageData);
        }
コード例 #2
0
        public async static Task <bool> checkIfImageFolderIsEmpty(OneDriveStorageFolder imageFolder)
        {
            bool isImageFolderEmpty = true;
            var  listOfItems        = new List <OneDriveStorageFile>();

            try
            {
                listOfItems = await imageFolder.GetFilesAsync();

                if (listOfItems.Count > 0)
                {
                    isImageFolderEmpty = false;
                }
            }
            catch (Exception)
            {
            }

            return(isImageFolderEmpty);
        }