当前位置: 首页>>代码示例>>C#>>正文


C# StorageFolder.GetFoldersAsync方法代码示例

本文整理汇总了C#中Windows.Storage.StorageFolder.GetFoldersAsync方法的典型用法代码示例。如果您正苦于以下问题:C# StorageFolder.GetFoldersAsync方法的具体用法?C# StorageFolder.GetFoldersAsync怎么用?C# StorageFolder.GetFoldersAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Storage.StorageFolder的用法示例。


在下文中一共展示了StorageFolder.GetFoldersAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAllFiles

        private async void GetAllFiles(StorageFolder folder, ObservableCollection<Song> songs)
        {
            foreach (StorageFile file in await folder.GetFilesAsync())
            {
                if(file.FileType == ".mp3")
                {
                    var props = await file.Properties.GetMusicPropertiesAsync();
                    var image = await file.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.MusicView);
                    var cover = new BitmapImage();
                    cover.SetSource(image);
                    Song song = new Song()
                    {
                        Name = props.Title,
                        Album = props.Album,
                        Artist = props.Artist,
                        Cover = cover,
                        File = file
                    };
                    songs.Add(song);
                }
            }

            foreach (StorageFolder subfolder in await folder.GetFoldersAsync())
            {
                GetAllFiles(subfolder, songs);
            }
        }
开发者ID:jeslas,项目名称:UWP-Playground,代码行数:27,代码来源:MediaLibrary.xaml.cs

示例2: getFiles

 public async Task getFiles(List<StorageFile> list, StorageFolder parent)
 {   //get all files of type folder search use Recursion
     foreach (var item in await parent.GetFilesAsync())
     {
         list.Add(item);
     }
     foreach (var item in await parent.GetFoldersAsync())
         await getFiles(list, item);
 }
开发者ID:sikyurabmt,项目名称:HQL,代码行数:9,代码来源:MusicManager.cs

示例3: getFiles

 public async Task getFiles(List<StorageFile> list, StorageFolder parent)
 {
     foreach (var item in await parent.GetFilesAsync())
     {
         list.Add(item);
     }
     foreach (var item in await parent.GetFoldersAsync())
         await getFiles(list, item);
 }
开发者ID:sikyurabmt,项目名称:HQL,代码行数:9,代码来源:MainPage.xaml.cs

示例4: MergeFolders

 internal async static Task MergeFolders(StorageFolder source, StorageFolder target)
 {
     foreach (StorageFile sourceFile in await source.GetFilesAsync())
     {
         await sourceFile.CopyAndReplaceAsync(await target.CreateFileAsync(sourceFile.Name, CreationCollisionOption.OpenIfExists));
     }
     
     foreach (StorageFolder sourceDirectory in await source.GetFoldersAsync())
     {
         StorageFolder nextTargetSubDir = await target.CreateFolderAsync(sourceDirectory.Name, CreationCollisionOption.OpenIfExists);
         await MergeFolders(sourceDirectory, nextTargetSubDir);
     }
 }
开发者ID:cmcewen,项目名称:react-native-code-push,代码行数:13,代码来源:FileUtils.cs

示例5: folderInitialisation

        private async void folderInitialisation(StorageFolder picturesFolder)
        {
            IReadOnlyList<StorageFolder> folderList = await picturesFolder.GetFoldersAsync();
            StringBuilder folderString = new StringBuilder(picturesFolder.Name + "\n\n");


            foreach (StorageFolder folder in folderList)
            {
                folderString.AppendLine("    " + folder.DisplayName + "\\");
            }

            folderText.Text = folderString.ToString();
        }
开发者ID:zirakai,项目名称:NyxoWp,代码行数:13,代码来源:PictureTest.xaml.cs

示例6: retrieveFilesInFolders

        private async Task retrieveFilesInFolders(ObservableCollection<StorageFile> list,StorageFolder parent)
        {
            foreach (var item in await parent.GetFilesAsync())
            {
                if (item.FileType == ".mp3")
                    list.Add(item);
            }

            foreach (var item in await parent.GetFoldersAsync())
            {
                await retrieveFilesInFolders(list, item);
            }
        }
开发者ID:sushantgoel,项目名称:AlbumMatchGame,代码行数:13,代码来源:MainPage.xaml.cs

示例7: GetFileCountInWhitelist

        /// <summary>
        /// Returns the number of files within the Oxford Whitelist
        /// </summary>
        public static async Task<int> GetFileCountInWhitelist(StorageFolder folder)
        {
            int fileCount = 0;

            fileCount += (await folder.GetFilesAsync()).Count;

            var subFolders = await folder.GetFoldersAsync();

            foreach(var subFolder in subFolders)
            {
                fileCount += (await subFolder.GetFilesAsync()).Count;
            }

            return fileCount;
        }
开发者ID:vishalishere,项目名称:Facial-Recognition-Door,代码行数:18,代码来源:FaceApiUtils.cs

示例8: RetriveFilesInFolder

        // first - a method to retrieve files from folder recursively 
        private static async Task RetriveFilesInFolder(List<StorageFile> list, StorageFolder parent)
        {
            list.AddRange((await parent.GetFilesAsync()).Where(p => 
                p.FileType == ".wma" 
                || p.FileType == ".flac"
                || p.FileType == ".m4a"
                || p.FileType == ".mp3"));

            //avoiding DRM folder of xbox music
            foreach (var folder in (await parent.GetFoldersAsync()).Where(folder =>
                folder.Name != "Xbox Music" && folder.Name != "Subscription Cache" && folder.Name != "Podcasts"))
            {
                await RetriveFilesInFolder(list, folder);
            }
        }
开发者ID:jayharry28,项目名称:Audiotica,代码行数:16,代码来源:LocalMusicHelper.cs

示例9: _getAllFilesInFolderRecurse

        async Task<List<string>> _getAllFilesInFolderRecurse(StorageFolder currentFolder, string topFolder)
        {
            List<string> files = new List<string>();

            foreach (var f in await currentFolder.GetFoldersAsync())
            {
                files.AddRange(await _getAllFilesInFolderRecurse(f, topFolder));
            }

            var filesResult = await currentFolder.GetFilesAsync();

            var filesString = filesResult.Select(_ => _.Path.Replace(topFolder, "").Trim('\\')).ToList();
            files.AddRange(filesString);
            return files;
        }
开发者ID:jakkaj,项目名称:Xamling-Core,代码行数:15,代码来源:LocalStorage.cs

示例10: DeleteFolderRecursivelyAsync

        private async Task DeleteFolderRecursivelyAsync(StorageFolder folder)
        {
            IReadOnlyList<StorageFolder> folders = await folder.GetFoldersAsync();
            if (folders.Count > 0)
            {
                foreach (StorageFolder subFolder in folders)
                {
                    await DeleteFolderRecursivelyAsync(subFolder);
                }
            }

            IReadOnlyList<StorageFile> files = await folder.GetFilesAsync();
            foreach (StorageFile file in files)
            {
                await file.DeleteAsync(StorageDeleteOption.PermanentDelete);
            }
        }
开发者ID:bcl-lab-apps,项目名称:EMRGENE,代码行数:17,代码来源:FolderObjectStore.cs

示例11: GetAllFolders

        public async void GetAllFolders(StorageFolder KnownFolders)
        {
            IReadOnlyList<StorageFolder> folderList = await KnownFolders.GetFoldersAsync();

            // Pluck off meta data from folders
            int id = 0;
            foreach (StorageFolder folder in folderList)
            {
                Folder Folder = new Folder();
                Folder.Id = id;
                Folder.Name = folder.Name;
                Folder.Path = folder.Path;
                Folder.FolderFile = folder;
                Folders.Add(Folder);
                id++;
            }
        }
开发者ID:zirakai,项目名称:NyxoWp,代码行数:17,代码来源:GetFolders.cs

示例12: FindJSBundleInUpdateContents

        internal async static Task<string> FindJSBundleInUpdateContents(StorageFolder updateFolder, string expectedFileName)
        {
            foreach (StorageFile file in await updateFolder.GetFilesAsync())
            {
                string fileName = file.Name;
                if (fileName.Equals(expectedFileName))
                {
                    return fileName;
                }
            }

            foreach (StorageFolder folder in await updateFolder.GetFoldersAsync())
            {
                string mainBundlePathInSubFolder = await FindJSBundleInUpdateContents(folder, expectedFileName);
                if (mainBundlePathInSubFolder != null)
                {
                    return Path.Combine(folder.Name, mainBundlePathInSubFolder);
                }
            }

            return null;
        }
开发者ID:cmcewen,项目名称:react-native-code-push,代码行数:22,代码来源:UpdateUtils.cs

示例13: ListFilesInFolder

        public async Task ListFilesInFolder(StorageFolder folder)
        {
            var foldersInFolder = await folder.GetFoldersAsync();

            foreach (StorageFolder currentChildFolder in foldersInFolder)
            {
                await ListFilesInFolder(currentChildFolder);
            }

            var filesInFolder = await folder.GetFilesAsync();
            foreach (StorageFile currentFile in filesInFolder)
            {
                if (currentFile.ContentType.IsImageFormat())
                {
                    var picture = new Picture(currentFile.Name, currentFile.DateCreated.DateTime, currentFile.Path);
                    if (!pictures.Contains(picture))
                    {
                        pictures.Add(picture);
                        await picture.LoadImageAsync();
                    }
                }
            }
        }
开发者ID:robertiagar,项目名称:Pixelator,代码行数:23,代码来源:PicturesViewModel.cs

示例14: ZipFolderContents

        /// <summary>
        /// ZipFolder and its sub folders
        /// </summary>
        /// <param name="tcpSocket"></param>
        async private static Task ZipFolderContents(StorageFolder sourceFolder, ZipArchive archive, string baseDirPath)
        {
            IReadOnlyList<StorageFile> files = await sourceFolder.GetFilesAsync();

            foreach (StorageFile file in files)
            {
                ZipArchiveEntry readmeEntry = archive.CreateEntry(GetCompressedFileName(baseDirPath, file));

                byte[] buffer = WindowsRuntimeBufferExtensions.ToArray(await FileIO.ReadBufferAsync(file));

                // And write the contents to it
                using (Stream entryStream = readmeEntry.Open())
                {
                    await entryStream.WriteAsync(buffer, 0, buffer.Length);
                }
            }

            IReadOnlyList<StorageFolder> subFolders = await sourceFolder.GetFoldersAsync();

            if (subFolders.Count() == 0) return;

            foreach (StorageFolder subfolder in subFolders)
                await ZipFolderContents(subfolder, archive, baseDirPath);
        }
开发者ID:vulcanlee,项目名称:Windows8Lab,代码行数:28,代码来源:FolderZip.cs

示例15: BrowseFolder

        public async System.Threading.Tasks.Task<uint> BrowseFolder(StorageFolder folder)
        {
            //     LogMessage("Discover folder Name: " + folder.Name + " Path: " + folder.Path + " files: [" + fileDiscovered + "] folders: [" + folderDiscovered + "]");
            folderDiscovered++;
            if (ProgressEvent != null)
                ProgressEvent(folderDiscovered);

            await System.Threading.Tasks.Task.Delay(100);
            try
            {

                if (discoverCancelToken != null)
                    if (discoverCancelToken.Token.IsCancellationRequested)
                        discoverCancelToken.Token.ThrowIfCancellationRequested();
                IReadOnlyList<StorageFolder> folders = await folder.GetFoldersAsync(CommonFolderQuery.DefaultQuery);
                foreach (var f in folders)
                {
                    if (discoverCancelToken != null)
                        if (discoverCancelToken.Token.IsCancellationRequested)
                            discoverCancelToken.Token.ThrowIfCancellationRequested();
                    uint value = await BrowseFolder(f);
                }
            }
            catch (Exception e)
            {
                LogMessage("Discover folder exception: " + folder.Path + " Exception:" + e.Message);
            }
            uint currentFilesDiscovered = fileDiscovered;
            try
            {
                if (discoverCancelToken != null)
                    if (discoverCancelToken.Token.IsCancellationRequested)
                        discoverCancelToken.Token.ThrowIfCancellationRequested();
                //                IReadOnlyList<StorageFile> files = await folder.GetFilesAsync(CommonFileQuery.OrderByName);
                IReadOnlyList<StorageFile> files = await folder.GetFilesAsync(CommonFileQuery.DefaultQuery);
                foreach (var f in files)
                {
                    if (discoverCancelToken != null)
                        if (discoverCancelToken.Token.IsCancellationRequested)
                            discoverCancelToken.Token.ThrowIfCancellationRequested();
                    string path = await GetPath(f);
                    string extension = f.FileType;
                    foreach (string e in extensionArray)
                    {
                        if (extension.EndsWith(e, StringComparison.CurrentCultureIgnoreCase))
                        {
                            if (!defaultMediaDictionary.ContainsKey(path))
                            {
                                MediaLibraryItem mli = new MediaLibraryItem(path);
                                defaultMediaDictionary.Add(path, mli);
                                fileDiscovered = (uint)defaultMediaDictionary.Count;
                            }
                            UpdateUI();
                            //statusValue.Text = fileDiscovered.ToString() + " files discovered";
                          //  LogMessage("Discover file name: " + f.Name + " path: " + path);
                            break;
                        }

                    }
                }
            }
            catch (Exception e)
            {
                LogMessage("Discover files exception: " + folder.Path + " Exception:" + e.Message);
            }
            if (currentFilesDiscovered != fileDiscovered)
            {
                UpdateCounter();
            }
            return fileDiscovered;
        }
开发者ID:flecoqui,项目名称:Windows10,代码行数:71,代码来源:MainPage.xaml.cs


注:本文中的Windows.Storage.StorageFolder.GetFoldersAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。