Пример #1
0
        /// <summary>
        /// Gets the parent folder of the current folder.
        /// </summary>
        /// <returns>When this method completes, it returns the parent folder as a <see cref="StorageFolder"/>.</returns>
        public Task <StorageFolder> GetParentAsync()
        {
#if WINDOWS_UWP || WINDOWS_APP
            return(Task.Run <StorageFolder>(async() =>
            {
                var f = await _folder.GetParentAsync();
                return f == null ? null : new StorageFolder(f);
            }));
#elif __ANDROID__ || __UNIFIED__ || WIN32 || TIZEN
            return(Task.Run <StorageFolder>(() =>
            {
                var parent = global::System.IO.Directory.GetParent(Path);
                return parent == null ? null : new StorageFolder(parent.FullName);
            }));
#elif WINDOWS_PHONE_APP || WINDOWS_PHONE
            return(Task.Run <StorageFolder>(async() =>
            {
                var parentPath = global::System.IO.Path.GetPathRoot(Path.TrimEnd('\\'));
                Windows.Storage.StorageFolder parent = null;
                if (!string.IsNullOrEmpty(parentPath))
                {
                    parent = await Windows.Storage.StorageFolder.GetFolderFromPathAsync(parentPath);
                }

                return parent == null ? null : new StorageFolder(parent);
            }));
#else
            throw new PlatformNotSupportedException();
#endif
        }