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


C# StorageFolder.CreateFileQueryWithOptions方法代碼示例

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


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

示例1: BrowseButton_Click

		private async void BrowseButton_Click(object sender, RoutedEventArgs e)
		{
			try
			{
				var folderPicker = new FolderPicker()
				{
					CommitButtonText = "Open",
					SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
					ViewMode = PickerViewMode.List
				};
				folderPicker.FileTypeFilter.Add(".shp");

				_folder = await folderPicker.PickSingleFolderAsync();
				if (_folder != null)
				{
					var qopts = new QueryOptions(CommonFileQuery.OrderByName, new string[] { ".shp" });
					var query = _folder.CreateFileQueryWithOptions(qopts);
					var files = await query.GetFilesAsync();
					FileListCombo.ItemsSource = files;
					FileListCombo.Visibility = (files.Any()) ? Visibility.Visible : Visibility.Collapsed;
				}
			}
			catch (Exception ex)
			{
				var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync();
			}
		}
開發者ID:MagicWang,項目名稱:arcgis-runtime-samples-dotnet,代碼行數:27,代碼來源:FeatureLayerFromShapefile.xaml.cs

示例2: GetAllVideos

        private async void GetAllVideos(StorageFolder KnownFolders, QueryOptions QueryOptions)
        {
            StorageFileQueryResult query = KnownFolders.CreateFileQueryWithOptions(QueryOptions);
            IReadOnlyList<StorageFile> folderList = await query.GetFilesAsync();

            // Get all the videos in the folder past in parameter
            int id = 0;
            foreach (StorageFile file in folderList)
            {
                using (StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.VideosView, 200, ThumbnailOptions.UseCurrentScale))
                {
                    // Get video's properties
                    VideoProperties videoProperties = await file.Properties.GetVideoPropertiesAsync();

                    BitmapImage VideoCover = new BitmapImage();
                    VideoCover.SetSource(thumbnail);

                    Video video = new Video();
                    video.Id = id;
                    video.Name = file.Name;
                    video.DateCreated = file.DateCreated.UtcDateTime;
                    video.FileType = file.FileType;
                    video.VideoPath = file.Path;
                    video.Duration = videoProperties.Duration;
                    video.VideoFile = file;
                    video.VideoCover = VideoCover;

                    // Add the video to the ObservableCollection
                    Videos.Add(video);
                    id++;
                }
            }
        }
開發者ID:zirakai,項目名稱:NyxoWp,代碼行數:33,代碼來源:GetVideos.cs

示例3: LoadFolderFiles

        public static async Task<List<StorageFile>> LoadFolderFiles(StorageFolder storageFolder)
        {
            var queryOptions = new QueryOptions
                       (
                       CommonFileQuery.OrderByName, new List<string> { ".3g2", ".3gp2", ".3gp", ".3gpp", ".m4a", ".m4v", ".mp4v", ".mp4", ".mov", ".m2ts", ".asf", ".wm", ".vob", ".wmv", ".wma", ".aac", ".adt", ".mp3", ".wav", ".avi", ".ac3", ".ec3" }
                       );

            var fileQuery = storageFolder.CreateFileQueryWithOptions(queryOptions);

            var ass = await fileQuery.GetFilesAsync();

            return ass.ToList();
        }
開發者ID:prabaprakash,項目名稱:Visual-Studio-2013,代碼行數:13,代碼來源:LoadFolder.cs

示例4: GetFolderSize

        private async Task<ulong> GetFolderSize(StorageFolder folder) {
            StorageFileQueryResult query = folder.CreateFileQueryWithOptions(new QueryOptions {
                FolderDepth = FolderDepth.Deep
            });

            IReadOnlyList<StorageFile> files = await query.GetFilesAsync();
            ulong size = 0;
            foreach (StorageFile file in files) {
                BasicProperties props = await file.GetBasicPropertiesAsync();
                size += props.Size;
            }

            return size;
        }
開發者ID:acedened,項目名稱:TheChan,代碼行數:14,代碼來源:CacheService.cs

示例5: ThumbnailsAsync

 /// <param name="filter">".jpg"</param>
 public async Task<List<Models.ImageInfo>> ThumbnailsAsync(StorageFolder folder, uint requestedSize = 190, params string[] filter)
 {
     var options = new QueryOptions(CommonFileQuery.OrderByName, filter);
     var query = folder.CreateFileQueryWithOptions(options);
     var files = (await query.GetFilesAsync() as IReadOnlyList<StorageFile>).ToList();
     var scale = ThumbnailOptions.UseCurrentScale;
     var mode = ThumbnailMode.PicturesView;
     var result = new List<Models.ImageInfo>();
     foreach (var file in files)
     {
         var thumbnail = await file.GetThumbnailAsync(mode, requestedSize, scale);
         result.Add(new Models.ImageInfo { File = file, Thumbnail = thumbnail });
     }
     return result;
 }
開發者ID:JerryNixon,項目名稱:KinectPhotoboothV2,代碼行數:16,代碼來源:FileService.cs

示例6: SetFolder

 // Set functionality for the folder
 public async Task SetFolder(StorageFolder folder)
 {
     //unhook the old contents changed event if applicable
     if (_queryResult != null)
     {
         _queryResult.ContentsChanged -= QueryResult_ContentsChanged;
     }
     // Initialize the query and register for changes
     _folder = folder;
     QueryOptions options = new QueryOptions();
     // options.IndexerOption = IndexerOption.DoNotUseIndexer;
     _queryResult = _folder.CreateFileQueryWithOptions(options);
     _queryResult.ContentsChanged += QueryResult_ContentsChanged;
     await UpdateCount();
 }
開發者ID:C-C-D-I,項目名稱:Windows-universal-samples,代碼行數:16,代碼來源:FileDataSource.cs

示例7: WatchedFolder

 public WatchedFolder(StorageFolder folder)
 {
     _folder = folder;
     _fileQueryResult = _folder.CreateFileQueryWithOptions(_queryOptions);
     _fileQueryResult.ContentsChanged += _fileQueryResult_ContentsChanged;
 }
開發者ID:sunnycase,項目名稱:TomatoMusic,代碼行數:6,代碼來源:WatchedFolder.cs

示例8: GenerateGallery

        /// <summary>
        /// Generates html for the gallery
        /// </summary>
        /// <param name="folder">Folder to read the pictures from</param>
        /// <param name="pageNumber">Page starting from 1</param>
        /// <param name="pageSize">Number of pictures on each page</param>
        /// <returns></returns>
        public async Task<string> GenerateGallery(StorageFolder folder, int pageNumber, int pageSize)
        {
            // Don't allow negatives
            if (pageNumber < 1) pageNumber = 1;
            if (pageSize < 1) pageSize = 1;

            var subFolders = await folder.GetFoldersAsync();
            var parentFolder = await folder.GetParentAsync();

            // JavaScript code for toggling the subfolder list
            string html = "";
            html += "<script type='text/javascript'>" +
                "function toggleSubfolderList(){"+
                "var folderNavPane = document.getElementById('folder_nav_pane');" +
                "if(folderNavPane.style.display == 'block') folderNavPane.style.display = 'none';" +
                "else folderNavPane.style.display = 'block'" +
                "}" +
                "</script>";

            html += "<table>";
            html += "<tr><td>";
            // Create breadcrumbs for folder nav
            var temp = folder;
            string breadcrumbs = "<b>"+ ((subFolders.Count > 0) ? "<a onclick='toggleSubfolderList()' href='javascript:void(0);'>" + temp.Name + "</a>" : temp.Name) + "</b>";
            while(!temp.Path.Equals(rootFolder.Path, StringComparison.OrdinalIgnoreCase))
            {
                temp = await temp.GetParentAsync();
                string hyperlink = MakeHyperlink(temp.Name, "/gallery.htm?folder=" + WebUtility.UrlEncode(temp.Path), false);
                breadcrumbs = hyperlink + " > " + breadcrumbs;
            }
            html += breadcrumbs + "<br>";

            if (subFolders.Count > 0)
            {
                // Generate subfolder navigation pane
                html += "<div id='folder_nav_pane' style='display:none'>";
                html += "<ul>";
                foreach (StorageFolder subFolder in subFolders)
                {
                    html += "<li><a href='/gallery.htm?folder=" + WebUtility.UrlEncode(subFolder.Path) + "'>" + subFolder.Name + "</a></li>";
                }
                html += "</ul></div>";
            }

            html += "<br></td></tr>";

            // Get the files in current folder and subfolders
            var queryOptions = new QueryOptions();
            queryOptions.FolderDepth = FolderDepth.Deep;

            var results = folder.CreateFileQueryWithOptions(queryOptions);
            
            StorageFile[] sortedFiles = null;

            // Use cached files if we already got the files and we're navigating to the first page
            if (cachedFiles != null && pageNumber != 1)
            {
                sortedFiles = cachedFiles;
            }
            else
            {
                var files = await results.GetFilesAsync();
                sortedFiles = files.OrderByDescending((x) => x.DateCreated).ToArray();
                cachedFiles = sortedFiles;
            }

            if (sortedFiles.Length > 0)
            {
                // Create pages
                string pagesHtml = "<form>";
                html += "<tr><td>";
                int totalPages = (int)Math.Ceiling((double)sortedFiles.Length / pageSize);
                pagesHtml += "Pages: ";

                pagesHtml += "<select name='page' onchange='this.form.submit()'>";

                for (int i = 1; i <= totalPages; i++)
                {
                    pagesHtml += "<option value='" + i + "' " + ((i == pageNumber) ? "selected='selected'" : "") + ">" + i + "</option>";
                }
                pagesHtml += "</select>";
                pagesHtml += "<input type='hidden' name='folder' value='" + folder.Path + "' />";
                pagesHtml += "<input type='hidden' name='pageSize' value='30' />";
                pagesHtml += "</form>";

                html += pagesHtml;
                html += "<br></td></tr>";

                html += "<tr><td>";

                // Pick out the subset of files we need based on page
                int startIndex = (pageNumber - 1) * pageSize;
                for (int i = startIndex; i < startIndex + pageSize; i++)
//.........這裏部分代碼省略.........
開發者ID:jadeiceman,項目名稱:securitysystem-1,代碼行數:101,代碼來源:WebHelper.cs

示例9: RefreshQueue

        /// <summary>
        /// 
        /// </summary>
        public async void RefreshQueue()
        {
            try
            {
                reportFolder = await KnownFolders.DocumentsLibrary.CreateFolderAsync("311_Reports_Folder", CreationCollisionOption.OpenIfExists);
            }
            catch (Exception) { /*NotifyUser("DOCUMENT ERROR", NotifyType.ReportMessage);*/ }

            try
            {
                pictureFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync("311_Pictures_Folder", CreationCollisionOption.OpenIfExists);
            }
            catch (Exception) { /*NotifyUser("PICTURE ERROR", NotifyType.ReportMessage);*/ }

            var queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, new[] { ".txt" });
            var query = reportFolder.CreateFileQueryWithOptions(queryOptions);
            var report_files = await query.GetFilesAsync();

            queryOptions = new QueryOptions(CommonFileQuery.DefaultQuery, new[] { ".png" });
            query = pictureFolder.CreateFileQueryWithOptions(queryOptions);
            var picture_files = await query.GetFilesAsync();

            //if (report_files.Count != picture_files.Count)
            //{
            //   await RemoveQueue(true);
            //}

            if ((queuedReportCount = report_files.Count) > 0)
            {
                ShowQueue(report_files, picture_files);
            }
            else
            {
                QueuedListView.Items.Clear();
                queuedListIndex.Clear();
            }
        }
開發者ID:retrohacker,項目名稱:SIUC311_Welling,代碼行數:40,代碼來源:MainPage.xaml.cs

示例10: GetFirstImageFromStorageAsync

        /// <summary>
        /// Finds and displays the first image file on the storage.
        /// </summary>
        /// <param name="storage"></param>
        async private Task GetFirstImageFromStorageAsync(StorageFolder storage)
        {
            var storageName = storage.Name;

            // Construct the query for image files
            var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, new List<string> { ".jpg", ".png", ".gif" });
            var imageFileQuery = storage.CreateFileQueryWithOptions(queryOptions);

            // Run the query for image files
            rootPage.NotifyUser("[Launched by Autoplay] Looking for images on " + storageName + " ...", NotifyType.StatusMessage);
            var imageFiles = await imageFileQuery.GetFilesAsync();
            if (imageFiles.Count > 0)
            {
                var imageFile = imageFiles[0];
                rootPage.NotifyUser("[Launched by Autoplay] Found " + imageFile.Name + " on " + storageName, NotifyType.StatusMessage);
                await DisplayImageAsync(imageFile);
            }
            else
            {
                rootPage.NotifyUser("[Launched by Autoplay] No images were found on " + storageName + ". You can use scenario 2 to transfer an image to it", NotifyType.StatusMessage);
            }
        }
開發者ID:oldnewthing,項目名稱:old-Windows8-samples,代碼行數:26,代碼來源:S4_Autoplay.xaml.cs

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

示例12: getResourceFilePaths

 private StorageFileQueryResult getResourceFilePaths(StorageFolder folder, IEnumerable<string> fileTypeFilters)
 {
     QueryOptions queryOptions = new QueryOptions(CommonFileQuery.OrderByName, fileTypeFilters);
     queryOptions.FolderDepth = FolderDepth.Deep;
     return folder.CreateFileQueryWithOptions(queryOptions);
 }
開發者ID:crb02005,項目名稱:RandomTablesUniversal,代碼行數:6,代碼來源:FileProvider.cs

示例13: AddFiles

        private async Task AddFiles(StorageFolder parentFolder)
        {
            var fileQuery = parentFolder.CreateFileQueryWithOptions(
                new QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByDate, new string[] { ".jpg", ".png" })
                );

            //Find up to 250 pictures in all sub folders of the parent folder

            var files = await fileQuery.GetFilesAsync(0, 250);

            foreach (var file in files)
            {
                string fileType = file.FileType.ToLowerInvariant();
                switch (fileType)
                {
                    case ".jpg":
                    case ".png":
                        lock (_allUris)
                        {
                            if (_allUris.Count >= MaxPhotos)
                            {
                                return;
                            }

                            string pathname = file.Path;
                            Uri uri = new Uri(pathname, UriKind.Absolute);
                            _allUris.Add(uri);
                        }
                        break;
                }
            }
        }
開發者ID:678uhb,項目名稱:composition,代碼行數:32,代碼來源:PhotoDatabase.cs


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