files-community/Files · warning · NotSupportedException
Specified method is not supported.
Error message
Specified method is not supported.
What it means
Thrown by VirtualStorageFolder.CreateItemQuery as NotSupportedException. VirtualStorageFolder is a lightweight, in-memory BaseStorageFolder that does not back a real Windows.Storage query. It does not implement the legacy StorageItemQueryResult surface; only the 'WithOptions' variant is supported (it returns a BaseStorageItemQueryResult).
Source
Thrown at src/Files.App/Utils/Storage/StorageItems/VirtualStorageFolder.cs:106
public override IAsyncOperation<BaseStorageFolder> CreateFolderAsync(string desiredName, CreationCollisionOption options) => throw new NotSupportedException(); public override IAsyncOperation<BaseStorageFolder> MoveAsync(IStorageFolder destinationFolder) => throw new NotSupportedException(); public override IAsyncOperation<BaseStorageFolder> MoveAsync(IStorageFolder destinationFolder, NameCollisionOption option) => throw new NotSupportedException(); public override IAsyncAction RenameAsync(string desiredName) => RenameAsync(desiredName, NameCollisionOption.FailIfExists); public override IAsyncAction RenameAsync(string desiredName, NameCollisionOption option) => throw new NotSupportedException(); public override IAsyncAction DeleteAsync() => throw new NotSupportedException(); public override IAsyncAction DeleteAsync(StorageDeleteOption option) => DeleteAsync(); public override bool AreQueryOptionsSupported(QueryOptions queryOptions) => false; public override bool IsCommonFileQuerySupported(CommonFileQuery query) => false; public override bool IsCommonFolderQuerySupported(CommonFolderQuery query) => false; public override StorageItemQueryResult CreateItemQuery() => throw new NotSupportedException(); public override BaseStorageItemQueryResult CreateItemQueryWithOptions(QueryOptions queryOptions) => new(this, queryOptions); public override StorageFileQueryResult CreateFileQuery() => throw new NotSupportedException(); public override StorageFileQueryResult CreateFileQuery(CommonFileQuery query) => throw new NotSupportedException(); public override BaseStorageFileQueryResult CreateFileQueryWithOptions(QueryOptions queryOptions) => new(this, queryOptions); public override StorageFolderQueryResult CreateFolderQuery() => throw new NotSupportedException(); public override StorageFolderQueryResult CreateFolderQuery(CommonFolderQuery query) => throw new NotSupportedException(); public override BaseStorageFolderQueryResult CreateFolderQueryWithOptions(QueryOptions queryOptions) => new(this, queryOptions); public override IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode) => Task.FromResult<StorageItemThumbnail>(null).AsAsyncOperation(); public override IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode, uint requestedSize) => Task.FromResult<StorageItemThumbnail>(null).AsAsyncOperation(); public override IAsyncOperation<StorageItemThumbnail> GetThumbnailAsync(ThumbnailMode mode, uint requestedSize, ThumbnailOptions options) => Task.FromResult<StorageItemThumbnail>(null).AsAsyncOperation(); } }
View on GitHub (pinned to 68c68a58d4)
Solutions
- Use CreateItemQueryWithOptions(queryOptions) instead, which is supported and returns a BaseStorageItemQueryResult.
- Check the folder type before calling; for VirtualStorageFolder, prefer GetItemsAsync directly.
- Catch NotSupportedException and fall back to the WithOptions overload or direct enumeration.
- If you must support the plain query, subclass VirtualStorageFolder and override CreateItemQuery to build a result over GetItemsAsync.
Example fix
// before var query = folder.CreateItemQuery(); // after var query = folder.CreateItemQueryWithOptions(new QueryOptions()); // or enumerate directly var items = await folder.GetItemsAsync();
Defensive patterns
Strategy: validation
Validate before calling
// Prefer the supported WithOptions query over the plain query.
BaseStorageItemQueryResult result =
folder is VirtualStorageFolder
? folder.CreateItemQueryWithOptions(new QueryOptions())
: folder.CreateItemQuery(); Type guard
static bool SupportsPlainItemQuery(BaseStorageFolder f) => f is not VirtualStorageFolder;
Try / catch
try { var q = folder.CreateItemQuery(); }
catch (NotSupportedException) { var q = folder.CreateItemQueryWithOptions(new QueryOptions()); } Prevention
- Use CreateItemQueryWithOptions for virtual folders.
- Guard with a type check before calling the plain query.
- Fall back to GetItemsAsync for direct enumeration.
When it happens
Trigger: Calling CreateItemQuery() on any VirtualStorageFolder instance. This happens when code requests the non-options query API, e.g. older WinRT-style enumeration or a consumer that does not use CreateItemQueryWithOptions.
Common situations: Third-party or legacy code calling the plain CreateItemQuery; search/indexing features that fall back to the parameterless query; generic algorithms that enumerate all query-creation entry points.
Related errors
- Copying folders is not supported.
- File already exists.
- Couldn't generate unique name. File skipped.
- File creation failed.
- Directory already exists.
AI-assisted analysis of files-community/Files@68c68a58d4 (2026-08-13).
Data as JSON: /api/errors/a1e031ad0d2af3ac.
Report an issue: GitHub.