Cannot access the specified file or folder (UNABLE_TO_MASK_PATH). Verify that the item is not marked with system or hidden file attributes
17:05 29 Apr 2026

I am currently working on a WinUI 3 (Windows App SDK) application where I need to display the user's desktop files and shortcuts. My goal is to read both the current user's desktop and the Public Desktop (CommonDesktopDirectory) and extract their icons using the Windows.Storage API.

While reading the current user's desktop works perfectly, my app crashes when trying to access the Public Desktop.

private async Task LoadRealIconsAsync()
{
    string publicDesktop = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);

    try
    {
        StorageFolder currentFolder = await StorageFolder.GetFolderFromPathAsync(publicDesktop);
        var folders = await currentFolder.GetFoldersAsync();

        foreach (StorageFolder folder in folders)
        {
            StorageItemThumbnail thumbnail = await folder.GetThumbnailAsync(ThumbnailMode.ListView, 64, ThumbnailOptions.UseCurrentScale);
            BitmapImage bitmapIcon = new BitmapImage();

            if (thumbnail != null) { await bitmapIcon.SetSourceAsync(thumbnail); }

            DesktopFiles.Add(new DesktopItem { Name = folder.Name, FileIcon = bitmapIcon });
        }

        var files = await currentFolder.GetFilesAsync();

        foreach (StorageFile file in files)
        {
            if (file.Name.ToLower() == "desktop.ini") continue;

            StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.ListView, 64, ThumbnailOptions.UseCurrentScale);
            BitmapImage bitmapIcon = new BitmapImage();

            if (thumbnail != null) { await bitmapIcon.SetSourceAsync(thumbnail); }

            string displayName = file.Name;
            if (displayName.EndsWith(".lnk", StringComparison.OrdinalIgnoreCase) ||
                displayName.EndsWith(".url", StringComparison.OrdinalIgnoreCase))
            {
                displayName = System.IO.Path.GetFileNameWithoutExtension(displayName);
            }

            DesktopFiles.Add(new DesktopItem { Name = displayName, FileIcon = bitmapIcon });
        }
    }
    catch (Exception ex)
    {
        DesktopFiles.Add(new DesktopItem
        {
            Name = $"{System.IO.Path.GetFileName(publicDesktop)}: {ex.Message}",
            FileIcon = null
        });
    }
}

but i get error:

Cannot access the specified file or folder (UNABLE_TO_MASK_PATH). Verify that the item is not marked with system or hidden file attributes.

id there any workarounds?

c# windows filesystems