@@ -828,30 +828,27 @@ public async Task<bool> EnumerateItemsFromStandardFolderAsync(string path)
828828 {
829829 _rootFolder = res . Result ;
830830 }
831- else if ( res == FilesystemErrorCode . ERROR_UNAUTHORIZED )
831+ else if ( _workingRoot != null )
832832 {
833- if ( ! CheckFolderForHiddenAttribute ( path ) ) // Is a standard location
833+ _rootFolder = _currentStorageFolder . Folder ;
834+ enumFromStorageFolder = true ;
835+ }
836+ else if ( ! CheckFolderAccessWithWin32 ( path ) ) // The folder is really inaccessible
837+ {
838+ if ( res == FilesystemErrorCode . ERROR_UNAUTHORIZED )
834839 {
835840 //TODO: proper dialog
836841 await DialogDisplayHelper . ShowDialogAsync (
837- "AccessDeniedDeleteDialog/Title" . GetLocalized ( ) ,
838- "SubDirectoryAccessDenied" . GetLocalized ( ) ) ;
842+ "AccessDeniedDeleteDialog/Title" . GetLocalized ( ) ,
843+ "SubDirectoryAccessDenied" . GetLocalized ( ) ) ;
839844 return false ;
840845 }
841- }
842- else if ( res == FilesystemErrorCode . ERROR_NOTFOUND )
843- {
844- await DialogDisplayHelper . ShowDialogAsync (
845- "FolderNotFoundDialog/Title" . GetLocalized ( ) ,
846- "FolderNotFoundDialog/Text" . GetLocalized ( ) ) ;
847- return false ;
848- }
849- else
850- {
851- if ( _workingRoot != null )
846+ else if ( res == FilesystemErrorCode . ERROR_NOTFOUND )
852847 {
853- _rootFolder = _currentStorageFolder . Folder ;
854- enumFromStorageFolder = true ;
848+ await DialogDisplayHelper . ShowDialogAsync (
849+ "FolderNotFoundDialog/Title" . GetLocalized ( ) ,
850+ "FolderNotFoundDialog/Text" . GetLocalized ( ) ) ;
851+ return false ;
855852 }
856853 else
857854 {
@@ -944,19 +941,19 @@ await DialogDisplayHelper.ShowDialogAsync(
944941 opacity = 0.4 ;
945942 }
946943
947- CurrentFolder = new ListedItem ( _rootFolder . FolderRelativeId , returnformat )
944+ CurrentFolder = new ListedItem ( null , returnformat )
948945 {
949946 PrimaryItemAttribute = StorageItemTypes . Folder ,
950947 ItemPropertiesInitialized = true ,
951- ItemName = _rootFolder . Name ,
948+ ItemName = Path . GetFileName ( path . TrimEnd ( ' \\ ' ) ) ,
952949 ItemDateModifiedReal = itemDate ,
953- ItemType = _rootFolder . DisplayType ,
950+ ItemType = "FileFolderListItem" . GetLocalized ( ) ,
954951 LoadFolderGlyph = true ,
955952 FileImage = null ,
956953 IsHiddenItem = isHidden ,
957954 Opacity = opacity ,
958955 LoadFileIcon = false ,
959- ItemPath = string . IsNullOrEmpty ( _rootFolder . Path ) ? _currentStorageFolder . Path : _rootFolder . Path ,
956+ ItemPath = path ,
960957 LoadUnknownTypeGlyph = false ,
961958 FileSize = null ,
962959 FileSizeBytes = 0
@@ -1086,6 +1083,20 @@ private async Task EnumFromStorageFolderAsync()
10861083 Debug . WriteLine ( $ "Enumerating items in { WorkingDirectory } (device) completed in { stopwatch . ElapsedMilliseconds } milliseconds.\n ") ;
10871084 }
10881085
1086+ public bool CheckFolderAccessWithWin32 ( string path )
1087+ {
1088+ FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS . FindExInfoBasic ;
1089+ int additionalFlags = FIND_FIRST_EX_LARGE_FETCH ;
1090+ IntPtr hFileTsk = FindFirstFileExFromApp ( path + "\\ *.*" , findInfoLevel , out WIN32_FIND_DATA findDataTsk , FINDEX_SEARCH_OPS . FindExSearchNameMatch , IntPtr . Zero ,
1091+ additionalFlags ) ;
1092+ if ( hFileTsk . ToInt64 ( ) != - 1 )
1093+ {
1094+ FindClose ( hFileTsk ) ;
1095+ return true ;
1096+ }
1097+ return false ;
1098+ }
1099+
10891100 public bool CheckFolderForHiddenAttribute ( string path )
10901101 {
10911102 FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS . FindExInfoBasic ;
0 commit comments