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


C# StorageFolder.GetFilesAsync方法代码示例

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


在下文中一共展示了StorageFolder.GetFilesAsync方法的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: GetNewFileName

        /// <summary>
        /// Gets a new filename which starts as the base filename parameter, but has a different end part.
        /// </summary>
        /// <param name="folder">The folder where the name will be checked.</param>
        /// <param name="baseFileName">Base filename to use as root.</param>
        /// <returns>
        /// The new filename.
        /// </returns>
        /// <example>
        /// In case that "naruto" does not exist in folder.
        /// GetNewFileName(folder, "naruto") -&gt; "naruto"
        /// GetNewFileName(folder, "naruto") -&gt; "naruto_1"
        /// GetNewFileName(folder, "naruto") -&gt; "naruto_2"
        /// ...
        ///   </example>
        public static string GetNewFileName(StorageFolder folder, string baseFileName)
        {
            try
            {
                var names = folder.GetFilesAsync()
                                .AsTask().Result
                                .Select(f => Path.GetFileNameWithoutExtension(f.Name));

                string possibleName = baseFileName;
                int index = 1;
                while (true)
                {
                    if (names.Any(n => n.Equals(possibleName, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        possibleName = baseFileName + index++;
                    }
                    else
                    {
                        break;
                    }
                }

                return possibleName;
            }
            catch (Exception)
            {
                return baseFileName;
            }
        }
开发者ID:molant,项目名称:MangApp,代码行数:44,代码来源:FileSystemUtilities.cs

示例3: GetMusics

 private async void GetMusics(StorageFolder folder)
 {
     // Get all the songs in the folder past in parameter
     foreach (var item in await folder.GetFilesAsync())
     {
         if (item.FileType == ".mp3")
             allSongs.Add(item);
     }
 }
开发者ID:zirakai,项目名称:NyxoWp,代码行数:9,代码来源:MusicControl.xaml.cs

示例4: SelectGameExecutables

        public async Task<int> SelectGameExecutables(StorageFolder folder)
        {
            IEnumerable<StorageFile> retrievedFiles = await folder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName);
            var fileCount = retrievedFiles.Count();

            Files = retrievedFiles.Where(file => ValidateFile(file)).ToList();

            return Files.Count;
        }
开发者ID:nzall,项目名称:GameRoulette,代码行数:9,代码来源:GameRouletteModel.cs

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: Initialize

 /// <summary>
 /// Initializes this instance.
 /// Load the images of Mobile Vikings team.
 /// </summary>
 /// <returns></returns>
 public async Task<bool> Initialize()
 {
     try
     {
         var assets = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");
         _folder = await assets.GetFolderAsync("People");
         _files = await _folder.GetFilesAsync();
     }
     catch (Exception ex)
     {
         return false;
     }
     return true;
 }
开发者ID:prebenh,项目名称:MobileVikings,代码行数:19,代码来源:Tweets.cs

示例10: LoadImagesFromDirectory

 private async void LoadImagesFromDirectory(StorageFolder imagesdirectory)
 {
     Images.Clear();
     var files = await imagesdirectory.GetFilesAsync();
     foreach (var file in files)
     {
         Images.Add(new PhotoDto
         {
             ID = Guid.NewGuid(),
             Image = await LoadImage(file)
         });
             
     }
 }
开发者ID:ma1982en,项目名称:curly-octo-pancake,代码行数:14,代码来源:ChoosingViewModel.cs

示例11: 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

示例12: _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

示例13: 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

示例14: GetAllPictures

        public async void GetAllPictures(StorageFolder folder)
        {
            // Get all the Pictures in the folder past in parameter
            foreach (var item in await folder.GetFilesAsync())
            {
                if (item.FileType == ".jpg" || item.FileType == ".jpeg"
                    || item.FileType == ".tif" || item.FileType == ".tiff"
                    || item.FileType == ".png" || item.FileType == ".gif"
                    || item.FileType == ".bmp" || item.FileType == ".dib"
                    || item.FileType == ".wdp")
                    allPictures.Add(item);
            }

            // Pluck off meta data from pictures
            GetInformationPictures(allPictures);
        }
开发者ID:zirakai,项目名称:NyxoWp,代码行数:16,代码来源:GetPictures.cs

示例15: 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


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