Esempio n. 1
0
        /// <summary>
        /// Gets the items in the current folder.
        /// </summary>
        /// <returns></returns>
        public Task <IReadOnlyList <IStorageItem> > GetItemsAsync()
        {
            List <IStorageItem> items = new List <IStorageItem>();

#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE
            return(Task.Run <IReadOnlyList <IStorageItem> >(async() =>
            {
                var found = await _folder.GetItemsAsync();
                foreach (var item in found)
                {
                    if (item.IsOfType(Windows.Storage.StorageItemTypes.File))
                    {
                        items.Add((StorageFile)((Windows.Storage.StorageFile)item));
                    }
                    else
                    {
                        items.Add((StorageFolder)((Windows.Storage.StorageFolder)item));
                    }
                }

                return items.AsReadOnly();
            }));
#elif __ANDROID__ || __UNIFIED__ || WIN32 || TIZEN
            return(Task.Run <IReadOnlyList <IStorageItem> >(() =>
            {
                foreach (string foldername in global::System.IO.Directory.GetDirectories(Path))
                {
                    items.Add(new StorageFolder(global::System.IO.Path.Combine(Path, foldername)));
                }

                foreach (string filename in global::System.IO.Directory.GetFiles(Path))
                {
                    items.Add(new StorageFile(global::System.IO.Path.Combine(Path, filename)));
                }

                return items.AsReadOnly();
            }));
#else
            throw new PlatformNotSupportedException();
#endif
        }