@@ -828,30 +828,27 @@ public async Task<bool> EnumerateItemsFromStandardFolderAsync(string path)
828
828
{
829
829
_rootFolder = res . Result ;
830
830
}
831
- else if ( res == FilesystemErrorCode . ERROR_UNAUTHORIZED )
831
+ else if ( _workingRoot != null )
832
832
{
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 )
834
839
{
835
840
//TODO: proper dialog
836
841
await DialogDisplayHelper . ShowDialogAsync (
837
- "AccessDeniedDeleteDialog/Title" . GetLocalized ( ) ,
838
- "SubDirectoryAccessDenied" . GetLocalized ( ) ) ;
842
+ "AccessDeniedDeleteDialog/Title" . GetLocalized ( ) ,
843
+ "SubDirectoryAccessDenied" . GetLocalized ( ) ) ;
839
844
return false ;
840
845
}
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 )
852
847
{
853
- _rootFolder = _currentStorageFolder . Folder ;
854
- enumFromStorageFolder = true ;
848
+ await DialogDisplayHelper . ShowDialogAsync (
849
+ "FolderNotFoundDialog/Title" . GetLocalized ( ) ,
850
+ "FolderNotFoundDialog/Text" . GetLocalized ( ) ) ;
851
+ return false ;
855
852
}
856
853
else
857
854
{
@@ -944,19 +941,19 @@ await DialogDisplayHelper.ShowDialogAsync(
944
941
opacity = 0.4 ;
945
942
}
946
943
947
- CurrentFolder = new ListedItem ( _rootFolder . FolderRelativeId , returnformat )
944
+ CurrentFolder = new ListedItem ( null , returnformat )
948
945
{
949
946
PrimaryItemAttribute = StorageItemTypes . Folder ,
950
947
ItemPropertiesInitialized = true ,
951
- ItemName = _rootFolder . Name ,
948
+ ItemName = Path . GetFileName ( path . TrimEnd ( ' \\ ' ) ) ,
952
949
ItemDateModifiedReal = itemDate ,
953
- ItemType = _rootFolder . DisplayType ,
950
+ ItemType = "FileFolderListItem" . GetLocalized ( ) ,
954
951
LoadFolderGlyph = true ,
955
952
FileImage = null ,
956
953
IsHiddenItem = isHidden ,
957
954
Opacity = opacity ,
958
955
LoadFileIcon = false ,
959
- ItemPath = string . IsNullOrEmpty ( _rootFolder . Path ) ? _currentStorageFolder . Path : _rootFolder . Path ,
956
+ ItemPath = path ,
960
957
LoadUnknownTypeGlyph = false ,
961
958
FileSize = null ,
962
959
FileSizeBytes = 0
@@ -1086,6 +1083,20 @@ private async Task EnumFromStorageFolderAsync()
1086
1083
Debug . WriteLine ( $ "Enumerating items in { WorkingDirectory } (device) completed in { stopwatch . ElapsedMilliseconds } milliseconds.\n ") ;
1087
1084
}
1088
1085
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
+
1089
1100
public bool CheckFolderForHiddenAttribute ( string path )
1090
1101
{
1091
1102
FINDEX_INFO_LEVELS findInfoLevel = FINDEX_INFO_LEVELS . FindExInfoBasic ;
0 commit comments