@@ -583,30 +583,42 @@ public async void RapidAddItemsToCollectionAsync(string path)
583
583
var fetchOperation = Task . Run ( async ( ) =>
584
584
{
585
585
_rootFolder = await StorageFolder . GetFolderFromPathAsync ( path ) ;
586
- QueryOptions options = new QueryOptions ( )
587
- {
588
- IndexerOption = IndexerOption . OnlyUseIndexerAndOptimizeForIndexedProperties ,
589
- FolderDepth = FolderDepth . Shallow
590
- } ;
591
- var query = _rootFolder . CreateItemQueryWithOptions ( options ) ;
592
- options . SetPropertyPrefetch ( PropertyPrefetchOptions . None , null ) ;
593
- options . SetThumbnailPrefetch ( ThumbnailMode . ListView , 40 , ThumbnailOptions . ReturnOnlyIfCached ) ;
594
- FileInformationFactory thumbnailFactory = new FileInformationFactory ( query , ThumbnailMode . ListView , 40 , ThumbnailOptions . ReturnOnlyIfCached , false ) ;
595
586
596
- var singlePurposedFiles = await thumbnailFactory . GetFilesAsync ( ) ;
597
- partialFiles = new System . Collections . ObjectModel . ObservableCollection < PartialStorageItem > ( ) ;
598
- foreach ( FileInformation info in singlePurposedFiles )
587
+ QueryOptions options = new QueryOptions ( ) ;
588
+ if ( await _rootFolder . GetIndexedStateAsync ( ) == IndexedState . FullyIndexed )
599
589
{
600
- partialFiles . Add ( new PartialStorageItem ( ) { RelativeId = info . FolderRelativeId , Thumbnail = await info . GetThumbnailAsync ( ThumbnailMode . ListView , 40 , ThumbnailOptions . ReturnOnlyIfCached ) , ItemName = info . Name , ContentType = info . DisplayType } ) ;
590
+ options . IndexerOption = IndexerOption . OnlyUseIndexerAndOptimizeForIndexedProperties ;
601
591
}
602
-
603
- var singlePurposedFolders = await thumbnailFactory . GetFoldersAsync ( ) ;
604
- partialFolders = new System . Collections . ObjectModel . ObservableCollection < PartialStorageItem > ( ) ;
605
- foreach ( FolderInformation info in singlePurposedFolders )
592
+ else
606
593
{
607
- partialFolders . Add ( new PartialStorageItem ( ) { RelativeId = info . FolderRelativeId , ItemName = info . Name , ContentType = null , Thumbnail = null } ) ;
594
+ options . IndexerOption = IndexerOption . UseIndexerWhenAvailable ;
608
595
}
596
+ options . FolderDepth = FolderDepth . Shallow ;
609
597
598
+ options . SetPropertyPrefetch ( PropertyPrefetchOptions . None , null ) ;
599
+ options . SetThumbnailPrefetch ( ThumbnailMode . ListView , 40 , ThumbnailOptions . ReturnOnlyIfCached ) ;
600
+ var query = _rootFolder . CreateItemQueryWithOptions ( options ) ;
601
+ var thumbnails = await query . GetItemsAsync ( 0 , 250 ) ;
602
+ uint index = 0 ;
603
+ partialFiles = new ObservableCollection < PartialStorageItem > ( ) ;
604
+ partialFolders = new ObservableCollection < PartialStorageItem > ( ) ;
605
+
606
+ while ( thumbnails . Count > 0 )
607
+ {
608
+ foreach ( IStorageItem item in thumbnails )
609
+ {
610
+ if ( item . IsOfType ( StorageItemTypes . Folder ) )
611
+ {
612
+ partialFolders . Add ( new PartialStorageItem ( ) { RelativeId = ( ( StorageFolder ) item ) . FolderRelativeId , ItemName = item . Name , ContentType = null , Thumbnail = null } ) ;
613
+ }
614
+ else
615
+ {
616
+ partialFiles . Add ( new PartialStorageItem ( ) { RelativeId = ( ( StorageFile ) item ) . FolderRelativeId , Thumbnail = await ( ( StorageFile ) item ) . GetThumbnailAsync ( ThumbnailMode . ListView , 40 , ThumbnailOptions . ReturnOnlyIfCached ) , ItemName = item . Name , ContentType = ( ( StorageFile ) item ) . DisplayType } ) ;
617
+ }
618
+ }
619
+ index += 250 ;
620
+ thumbnails = await query . GetItemsAsync ( index , 250 ) ;
621
+ }
610
622
611
623
} ) ;
612
624
@@ -624,16 +636,20 @@ public async void RapidAddItemsToCollectionAsync(string path)
624
636
{
625
637
do
626
638
{
627
- if ( ( ( FileAttributes ) findData . dwFileAttributes & FileAttributes . Directory ) != FileAttributes . Directory )
639
+ if ( ( ( FileAttributes ) findData . dwFileAttributes & FileAttributes . Hidden ) != FileAttributes . Hidden && ( ( FileAttributes ) findData . dwFileAttributes & FileAttributes . System ) != FileAttributes . System )
628
640
{
629
- AddFile ( findData , path , null ) ;
630
- ++ count ;
631
- }
632
- else if ( ( ( FileAttributes ) findData . dwFileAttributes & FileAttributes . Directory ) == FileAttributes . Directory )
633
- {
634
- AddFolder ( findData , path , null ) ;
635
- ++ count ;
641
+ if ( ( ( FileAttributes ) findData . dwFileAttributes & FileAttributes . Directory ) != FileAttributes . Directory )
642
+ {
643
+ AddFile ( findData , path , null ) ;
644
+ ++ count ;
645
+ }
646
+ else if ( ( ( FileAttributes ) findData . dwFileAttributes & FileAttributes . Directory ) == FileAttributes . Directory )
647
+ {
648
+ AddFolder ( findData , path , null ) ;
649
+ ++ count ;
650
+ }
636
651
}
652
+
637
653
} while ( FindNextFile ( hFile , out findData ) ) ;
638
654
639
655
FindClose ( hFile ) ;
0 commit comments