コード例 #1
0
        private static IFolder GetFolder(StorageFolder storageFolder)
        {
            IFolder folder = null;

            folder = new SFWinRTFolder(storageFolder, isRootFolder: true);
            return(folder);
        }
コード例 #2
0
 /// <summary>
 /// Convert from StorageFolder to IFolder
 /// </summary>
 /// <param name="storageFolder">Target folder</param>
 /// <returns>Converted folder</returns>
 public static Task <IFolder> ToPCLFolderAsync(this Windows.Storage.StorageFolder storageFolder)
 {
     if (string.IsNullOrEmpty(storageFolder.Path))
     {
         var sfFolder = new SFWinRTFolder(storageFolder);
         return(Task.FromResult(sfFolder as IFolder));
     }
     else
     {
         return(FileSystem.Current.GetFolderFromPathAsync(storageFolder.Path));
     }
 }
コード例 #3
0
        /// <summary>
        /// Gets a subfolder in this folder
        /// </summary>
        /// <param name="name">The name of the folder to get</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>The requested folder, or null if it does not exist</returns>
        public async Task <IFolder> TryGetFolderAsync(string name, CancellationToken cancellationToken)
        {
            IFolder folder = null;

            if (!cancellationToken.IsCancellationRequested)
            {
                var storageFolder = await TryGetItemAsync(name).ConfigureAwait(false) as IStorageFolder;

                if (storageFolder != null)
                {
                    folder = new SFWinRTFolder(storageFolder);
                }
            }
            return(folder);
        }