當前位置: 首頁>>代碼示例>>C#>>正文


C# StorageFolder.CreateFileQuery方法代碼示例

本文整理匯總了C#中Windows.Storage.StorageFolder.CreateFileQuery方法的典型用法代碼示例。如果您正苦於以下問題:C# StorageFolder.CreateFileQuery方法的具體用法?C# StorageFolder.CreateFileQuery怎麽用?C# StorageFolder.CreateFileQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.Storage.StorageFolder的用法示例。


在下文中一共展示了StorageFolder.CreateFileQuery方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Initialize

        public async Task Initialize(ICamera camera, IStorage storage)
        {
            this.camera = camera;
            this.storage = storage;

            var cacheFolder = KnownFolders.PicturesLibrary;
            this.dropFolder = await cacheFolder.GetFolderAsync("securitysystem-cameradrop");
            this.dropFolderWatcher = dropFolder.CreateFileQuery();

            var images = await this.dropFolderWatcher.GetFilesAsync();
            var orderedImages = images.OrderByDescending(x => x.DateCreated);
            this.newestImage = orderedImages.FirstOrDefault();

            this.dropFolderWatcher.ContentsChanged += DropFolderWatcher_ContentsChanged;

            this.allJoynBusAttachment = new AllJoynBusAttachment();
            this.producer = new SecuritySystemProducer(this.allJoynBusAttachment);
            this.allJoynBusAttachment.AboutData.DefaultAppName = Package.Current.DisplayName;
            this.allJoynBusAttachment.AboutData.DefaultDescription = Package.Current.Description;
            this.allJoynBusAttachment.AboutData.DefaultManufacturer = Package.Current.Id.Publisher;
            this.allJoynBusAttachment.AboutData.SoftwareVersion = Package.Current.Id.Version.ToString();
            this.allJoynBusAttachment.AboutData.IsEnabled = true;
            this.producer.Service = this;
            this.producer.Start();
        }
開發者ID:VictorBarbosa,項目名稱:securitysystem,代碼行數:25,代碼來源:AllJoynManager.cs

示例2: GetFolderSize

        public static async Task<double> GetFolderSize(StorageFolder folder)
        {
            
            // Query all files in the folder. Make sure to add the CommonFileQuery
            // So that it goes through all sub-folders as well
            var folders = folder.CreateFileQuery(CommonFileQuery.OrderByName);

            // Await the query, then for each file create a new Task which gets the size
            var fileSizeTasks = (await folders.GetFilesAsync()).Select(async file => (await file.GetBasicPropertiesAsync()).Size);

            // Wait for all of these tasks to complete. WhenAll thankfully returns each result
            // as a whole list
            var sizes = await Task.WhenAll(fileSizeTasks);

            // Sum all of them up. You have to convert it to a long because Sum does not accept ulong.
            var folderSize = sizes.Sum(l => (long)l);

            return folderSize;
        }
開發者ID:startewho,項目名稱:CnBetaUWA,代碼行數:19,代碼來源:IOHelper.cs

示例3: GetMediaFromFolder

        private static async Task<IReadOnlyList<StorageFile>> GetMediaFromFolder(StorageFolder folder,
                                                                            CommonFileQuery query)
        {
            IReadOnlyList<StorageFile> files = null;
            StorageFileQueryResult fileQuery;
            var queryOptions = new QueryOptions(query,
                                               new List<string>
                                               {
                                                   ".3g2",
                                                   ".3gp",
                                                   ".3gp2",
                                                   ".3gpp",
                                                   ".amv",
                                                   ".asf",
                                                   ".avi",
                                                   ".divx",
                                                   ".drc",
                                                   ".dv",
                                                   ".f4v",
                                                   ".flv",
                                                   ".gvi",
                                                   ".gxf",
                                                   ".ismv",
                                                   ".iso",
                                                   ".m1v",
                                                   ".m2v",
                                                   ".m2t",
                                                   ".m2ts",
                                                   ".m3u8",
                                                   ".mkv",
                                                   ".mov",
                                                   ".mp2",
                                                   ".mp2v",
                                                   ".mp4",
                                                   ".mp4v",
                                                   ".mpe",
                                                   ".mpeg",
                                                   ".mpeg1",
                                                   ".mpeg2",
                                                   ".mpeg4",
                                                   ".mpg",
                                                   ".mpv2",
                                                   ".mts",
                                                   ".mtv",
                                                   ".mxf",
                                                   ".mxg",
                                                   ".nsv",
                                                   ".nut",
                                                   ".nuv",
                                                   ".ogm",
                                                   ".ogv",
                                                   ".ogx",
                                                   ".ps",
                                                   ".rec",
                                                   ".rm",
                                                   ".rmvb",
                                                   ".tob",
                                                   ".ts",
                                                   ".tts",
                                                   ".vob",
                                                   ".vro",
                                                   ".webm",
                                                   ".wm",
                                                   ".wmv",
                                                   ".wtv",
                                                   ".xesc",
                                               });

            try
            {
                fileQuery = folder.CreateFileQueryWithOptions(queryOptions);

                files = await fileQuery.GetFilesAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("exception listing files");
                Debug.WriteLine(ex.ToString());
            }
            // DLNA folders don't support advanced file listings, us a basic file query
            if (files == null)
            {
                fileQuery = folder.CreateFileQuery(CommonFileQuery.OrderByName);
                files = await fileQuery.GetFilesAsync();
            }

            return files;
        }
開發者ID:kusl,項目名稱:vlcwinrt,代碼行數:88,代碼來源:VideoLibraryViewModel.cs


注:本文中的Windows.Storage.StorageFolder.CreateFileQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。