files-community/Files · error · NotSupportedException

Specified method is not supported.

Error message

Specified method is not supported.

What it means

ZipStorageFile overrides BaseStorageFile.GetParentAsync to throw NotSupportedException. A file inside a ZIP archive has no single real WinRT parent folder object the implementation can return, so the operation is unsupported rather than unimplemented. The root archive container and inner entries alike return this failure.

Source

Thrown at src/Files.App/Utils/Storage/StorageItems/ZipStorageFile.cs:100

				return Task.FromResult<BaseStorageFile>(null).AsAsyncOperation();

			if (path == containerPath)
				return Task.FromResult<BaseStorageFile>(null).AsAsyncOperation(); // Root

			if (CheckAccess(containerPath))
			{
				var file = new ZipStorageFile(path, containerPath);
				if (ZipStorageFolder.TryGetEncodingForContainerPath(containerPath, out var encoding))
					file.CurrentEncoding = encoding;
				return Task.FromResult<BaseStorageFile>(file).AsAsyncOperation();
			}
			return Task.FromResult<BaseStorageFile>(null).AsAsyncOperation();
		}

		public override bool IsEqual(IStorageItem item) => item?.Path == Path;
		public override bool IsOfType(StorageItemTypes type) => type is StorageItemTypes.File;

		public override IAsyncOperation<BaseStorageFolder> GetParentAsync() => throw new NotSupportedException();
		public override IAsyncOperation<BaseBasicProperties> GetBasicPropertiesAsync()
		{
			return AsyncInfo.Run(async (cancellationToken) =>
			{
				if (CurrentEncoding is not null && Path != containerPath)
					return await GetBasicPropertiesWithEncodingAsync();

				return await GetBasicProperties();
			});
		}

		public override IAsyncOperation<IRandomAccessStream> OpenAsync(FileAccessMode accessMode)
		{
			if (CurrentEncoding is not null && Path != containerPath)
				return OpenWithEncodingAsync(accessMode);

			return AsyncInfo.Run((cancellationToken) => SafetyExtensions.Wrap<IRandomAccessStream>(async () =>
			{

View on GitHub (pinned to 68c68a58d4)

Solutions

  1. Before calling GetParentAsync, check whether the item is a ZipStorageFile/ZipStorageFolder; if so, compute the parent path string directly instead of using the async API.
  2. Derive the parent from item.Path (strip the last path segment) rather than asking the storage object.
  3. Catch NotSupportedException and fall back to a path-based parent computation.

Example fix

// before
var parent = await zipFile.GetParentAsync(); // throws

// after
var parentPath = System.IO.Path.GetDirectoryName(zipFile.Path);
var parent = string.IsNullOrEmpty(parentPath) ? null : await BaseStorageFolder.GetFolderFromPathAsync(parentPath);
Defensive patterns

Strategy: validation

Validate before calling

static bool HasParentAsync(IStorageFile f) => f is not ZipStorageFile;

Type guard

static bool IsZipBacked(IStorageItem item) => item is ZipStorageFile or ZipStorageFolder;

Try / catch

try { return await file.GetParentAsync(); }
catch (NotSupportedException) { /* compute parent from Path */ }

Prevention

When it happens

Trigger: Calling GetParentAsync() on a ZipStorageFile (either the archive root or a file entry inside it). For example, code that walks up the directory tree via GetParentAsync to compute ancestry or to navigate to the containing folder.

Common situations: Breadcrumb/up-navigation logic, or any generic folder-tree traversal that assumes every IStorageItem has a resolvable parent, when the current item is a zip-backed file.

Related errors


AI-assisted analysis of files-community/Files@68c68a58d4 (2026-08-13). Data as JSON: /api/errors/3c152c95a0a56875. Report an issue: GitHub.