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


C# StorageFolder.GetItemsAsync方法代码示例

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


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

示例1: LoadFolder

        private async Task LoadFolder(StorageFolder folder, DateTime lastSync)
        {
            if (isCanceled) return;

            IReadOnlyList<IStorageItem> fileList = await folder.GetItemsAsync();

            foreach (IStorageItem storageItem in fileList)
            {
                if (storageItem.IsOfType(StorageItemTypes.File))
                {
                    StorageFile storageFile = DebugHelper.CastAndAssert<StorageFile>(storageItem);

                    await LoadFile(storageFile);
                }
                else if (storageItem.IsOfType(StorageItemTypes.Folder))
                {
                    StorageFolder storageFolder = DebugHelper.CastAndAssert<StorageFolder>(storageItem);

                    BasicProperties basicProperties = await storageFolder.GetBasicPropertiesAsync();

                    DateTime candidateTime = basicProperties.DateModified.UtcDateTime;

                    if (candidateTime > lastSync)
                    {
                        await LoadFolder(storageFolder, lastSync);
                    }
                }
            }
        }
开发者ID:jevonsflash,项目名称:ProjectMato,代码行数:29,代码来源:LocalMusicLibraryStorageProvider.cs

示例2: DeleteFolder

        public static async Task<bool> DeleteFolder(StorageFolder folder)
        {
            var folders = await folder.GetItemsAsync();
            for (int i = 0; i < folders.Count; i++)
            {
                 DeletItem(folders[i]);
            }

        
            
            return true;
        }
开发者ID:startewho,项目名称:CnBetaUWA,代码行数:12,代码来源:IOHelper.cs

示例3: ClearFiles

 public static async Task ClearFiles(StorageFolder folder)
 {
     try
     {
         foreach (IStorageItem item in await folder.GetItemsAsync())
         {
             if (item.IsOfType(StorageItemTypes.Folder))
             {
                 await ClearFiles((StorageFolder) item);
             }
             else
             {
                 await item.DeleteAsync();
             }
         }
     }
     catch (FileNotFoundException)
     {
     }
 }
开发者ID:sensorberg-dev,项目名称:windows10-sdk,代码行数:20,代码来源:TestHelper.cs

示例4: GetAllFiles

 private async Task GetAllFiles(StorageFolder storageFolder, List<StorageFile> musicFiles)
 {
     foreach (var item in await storageFolder.GetItemsAsync())
         if (item is StorageFile)
         {
             var file = item as StorageFile;
             if (file.ContentType.StartsWith("audio") && !file.ContentType.EndsWith("url"))
                 musicFiles.Add(file);
         }
         else
         {
             var folder = item as StorageFolder;
             await this.GetAllFiles(folder, musicFiles);
         }
 }
开发者ID:KennethYap,项目名称:MonoGame,代码行数:15,代码来源:MediaLibrary.WinRT.cs

示例5: GetFilesFromSubFolders

 private static async Task GetFilesFromSubFolders(StorageFolder folder, List<StorageFile> files)
 {
     try
     {
         var items = await folder.GetItemsAsync();
         foreach (IStorageItem storageItem in items)
         {
             if (storageItem.IsOfType(StorageItemTypes.Folder))
                 await GetFilesFromSubFolders(storageItem as StorageFolder, files);
             else if (storageItem.IsOfType(StorageItemTypes.File))
             {
                 var file = storageItem as StorageFile;
                 if (VLCFileExtensions.VideoExtensions.Contains(file.FileType.ToLower()))
                 {
                     files.Add(file);
                 }
             }
         }
     }
     catch (Exception e)
     {
         ExceptionHelper.CreateMemorizedException("VideoLibraryManagement.GetFilesFromSubFolders", e);
     }
 }
开发者ID:robUx4,项目名称:vlc-winrt,代码行数:24,代码来源:VideoLibraryManagement.cs

示例6: FilesNumber

        private async Task FilesNumber(StorageFolder cartella)
        {
            var Items = await cartella.GetItemsAsync();
            foreach(IStorageItem Item in Items)
            {
                if(Item.IsOfType(StorageItemTypes.Folder))
                {
                    await FilesNumber((StorageFolder)Item);
                }
                else if(Item.IsOfType(StorageItemTypes.File))
                {
                    file_count++;

                    BasicProperties bp = await ((StorageFile)Item).GetBasicPropertiesAsync();
                    file_size+= bp.Size;

                }
            }
        }
开发者ID:Lukasss93,项目名称:AuraRT,代码行数:19,代码来源:StorageHelper.cs

示例7: CreateBackup

        public static async Task<byte[]> CreateBackup(StorageFolder folder)
        {
            using (var autcpStream = new MemoryStream())
            {
                // add header now
                AddHeader(autcpStream);

                using (var zipArchive = new ZipArchive(autcpStream, ZipArchiveMode.Create))
                {
                    var filesToCompress = await folder.GetItemsAsync();

                    foreach (var item in filesToCompress)
                    {
                        var files = new List<StorageFile>();

                        if (item is StorageFile)
                        {
                            var file = item as StorageFile;
                            if (file.FileType == ".autcp" || file.Name.ToLower().StartsWith("xam")
                                || file.Name.StartsWith("_"))
                            {
                                continue;
                            }

                            files.Add(file);
                        }
                        else if (item is StorageFolder)
                        {
                            var name = (item as StorageFolder).Name;
                            if (name == "SOMA" || name == "Logs" || name == "AdMediator" || name == "artists" || name == "artworks")
                            {
                                continue;
                            }

                            files.AddRange(await (item as StorageFolder).GetFilesAsync());
                        }

                        foreach (var file in files)
                        {
                            var buffer = await FileIO.ReadBufferAsync(file);

                            if (buffer.Length == 0)
                            {
                                continue;
                            }

                            var bytes = buffer.ToArray();

                            var path = file.Path.Replace(folder.Path + "\\", string.Empty).Replace("\\", "/");

                            var entry = zipArchive.CreateEntry(path, CompressionLevel.Optimal);
                            using (var entryStream = entry.Open())
                            {
                                await entryStream.WriteAsync(bytes, 0, bytes.Length);
                                await entryStream.FlushAsync();
                            }
                        }
                    }
                }

                

                return autcpStream.ToArray();
            }
        }
开发者ID:jayharry28,项目名称:Audiotica,代码行数:65,代码来源:AutcpHelper.cs

示例8: GetFilesAsync

 private IObservable<StorageFile> GetFilesAsync(StorageFolder folder)
 {
     var obsItems = folder.GetItemsAsync().ToObservable();
     var files = (from item in obsItems
                  from i in item
                  select i is StorageFile ? Observable.Return((StorageFile)i) : GetFilesAsync((StorageFolder)i))
                  .SelectMany(i => i);
     return files;
 }
开发者ID:scemino,项目名称:nscumm,代码行数:9,代码来源:GameLibraryViewModel.cs

示例9: CopyFolder

    /// <summary>
    /// Copy a <see cref="StorageFolder"/> and its content to a specified directory
    /// </summary>
    /// <param name="source">the source folder</param>
    /// <param name="destination">the destination folder where create the copy</param>
    /// <param name="directoryName">the copy directory</param>
    /// <returns></returns>
    public async Task<bool> CopyFolder(StorageFolder source, StorageFolder destination, string directoryName)
    {
      //using (await InstanceLock.LockAsync())
      //{
      var isCopied = true;

      try
      {
        directoryName = directoryName.Replace("/", "\\");
        await CreateDirectory(destination, directoryName);
        var folderDest = await destination.GetFolderAsync(directoryName);
        if (folderDest != null)
        {
          var items = await source.GetItemsAsync();
          foreach (var item in items)
          {
            if (item.IsOfType(StorageItemTypes.File) == true)
            {
              isCopied = await CopyFile(source, folderDest, item.Name);
            }
            else if (item.IsOfType(StorageItemTypes.Folder) == true)
            {
              isCopied = await CopyFolder(source, folderDest, item.Name);
            }

            if (isCopied == false)
            {
              throw new Exception("Fail to copy item");
            }
          }
        }
        else
        {
          throw new Exception("Fail to create new directory");
        }
      }
      catch
      {
        isCopied = false;
      }

      return isCopied;
      //}
    }
开发者ID:smartnsoft,项目名称:ModernApp4Me,代码行数:51,代码来源:M4MFilePersistence.cs

示例10: SearchAllinFolder

        public static async Task<List<IStorageFile>> SearchAllinFolder(StorageFolder tempFolder)
        {
            try
            {
                IReadOnlyList<IStorageItem> tempList = await tempFolder.GetItemsAsync();
                List<IStorageFile> finalList = new List<IStorageFile>();
                if (tempList.Count == 0)
                    return finalList;
                foreach (var item in tempList)
                {
                    if (item is StorageFolder)
                    {
                        finalList.AddRange(await SearchAllinFolder((StorageFolder)item));
                    }
                    if (item is StorageFile)
                    {
                        if (tempTypeStrings.Contains(((StorageFile)item).FileType))
                        {
                            finalList.Add((StorageFile)item);
                        }
                    }
                }
                return finalList;
            }
            catch (Exception)
            {
                return new List<IStorageFile>();
            }

        }
开发者ID:aurora-lzzp,项目名称:com.aurora.aumusic,代码行数:30,代码来源:AlbumEnum.cs

示例11: DeleteFolderContentAsync

 public static async Task DeleteFolderContentAsync(StorageFolder folder)
 {
     var items = await folder.GetItemsAsync();
     foreach (var storageItem in items)
         await storageItem.DeleteAsync();
 }
开发者ID:haroldma,项目名称:Universal.Torrent,代码行数:6,代码来源:StorageHelper.cs

示例12: showSequenceForFolder

        private async void showSequenceForFolder(StorageFolder sf, bool repeat)
        {
            if (stopSequence) return;

            IReadOnlyList<IStorageItem> snapList = await sf.GetItemsAsync();

            try
            {

            for (int i=0; i < snapList.Count; i++)
            {
                StorageFile currFile = await sf.GetFileAsync(snapList[i].Name);

                BitmapImage bmpimg = await ImageController.GetImage(currFile);
                sequenceElement.Source = bmpimg;
                screensaverView.Source = bmpimg;

                await Task.Delay(TimeSpan.FromMilliseconds(150));
            }
            }
            catch (Exception ex)
            {
                addMessage("exception caught in sequence: " + ex.Message);
            }

            if (repeat) this.showSequenceForFolder(sf,repeat);
        }
开发者ID:karlsburg,项目名称:ReasonCam,代码行数:27,代码来源:ShootPage.xaml.cs

示例13: ScanDirectoryAsync

        private async Task ScanDirectoryAsync(StorageFolder storageFolder, bool doSha1, IObserver<string> starts, IObserver<FileInfo> completes)
        {
            foreach (var entry in await storageFolder.GetItemsAsync()) {
                var folder = entry as StorageFolder; // folder
                if (folder != null) {
                    starts.OnNext(folder.Name);

                    var innerStarts = new Subject<string>();
                    var innerCompletes = new Subject<FileInfo>();
                    var _ = Task.Run(() => ScanDirectoryAsync(folder, false, innerStarts, innerCompletes));

                    var totalSize = await innerStarts
                        .Zip(innerCompletes, (s, f) => (double)f.Size)
                        .Sum(x => x).FirstAsync();

                    completes.OnNext(new FileInfo { Name = folder.Name, Size = (ulong)totalSize });
                }

                var file = entry as StorageFile; // file
                if (file != null) {
                    starts.OnNext(file.Name);
                    var fileInfo = await ScanFile(file, doSha1).ConfigureAwait(false);
                    completes.OnNext(fileInfo);
                }
            }
            starts.OnCompleted();
            completes.OnCompleted();
        }
开发者ID:Porges,项目名称:Ignite2015,代码行数:28,代码来源:MainPage.xaml.cs


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