{"record":{"id":"53696222bf1ee340","repo":"files-community/Files","slug":"moving-to-recycle-bin-is-not-supported-536962","errorCode":null,"errorMessage":"Moving to recycle bin is not supported.","messagePattern":"Moving to recycle bin is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs","lineNumber":576,"sourceCode":"\n\t\tpublic override IAsyncAction DeleteAsync() => DeleteAsync(StorageDeleteOption.Default);\n\t\tpublic override IAsyncAction DeleteAsync(StorageDeleteOption option)\n\t\t{\n\t\t\treturn AsyncInfo.Run((cancellationToken) => SafetyExtensions.WrapAsync(async () =>\n\t\t\t{\n\t\t\t\tif (Path == containerPath)\n\t\t\t\t{\n\t\t\t\t\tif (backingFile is not null)\n\t\t\t\t\t{\n\t\t\t\t\t\tawait backingFile.DeleteAsync();\n\t\t\t\t\t}\n\t\t\t\t\telse if (option == StorageDeleteOption.PermanentDelete)\n\t\t\t\t\t{\n\t\t\t\t\t\tPInvoke.DeleteFileFromApp(Path);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new NotSupportedException(\"Moving to recycle bin is not supported.\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvar index = await FetchZipIndex();\n\t\t\t\t\tif (index.IsEmpty())\n\t\t\t\t\t{\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tusing (var ms = new MemoryStream())\n\t\t\t\t\t{\n\t\t\t\t\t\tawait using (var archiveStream = await OpenZipFileAsync(FileAccessMode.Read))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tSevenZipCompressor compressor = new SevenZipCompressor() { CompressionMode = CompressionMode.Append };\n\t\t\t\t\t\t\tcompressor.CustomParameters.Add(\"cu\", \"on\");\n\t\t\t\t\t\t\tcompressor.SetFormatFromExistingArchive(archiveStream);\n\t\t\t\t\t\t\tvar entriesMap = new Dictionary<int, string>(index.Select(x => new KeyValuePair<int, string>(x.Index, null)));\n\t\t\t\t\t\t\tawait compressor.ModifyArchiveAsync(archiveStream, entriesMap, Credentials.Password, ms);","sourceCodeStart":558,"sourceCodeEnd":594,"githubUrl":"https://github.com/files-community/Files/blob/68c68a58d4d6a5f7197e07c8fff85cfd4279c78b/src/Files.App/Utils/Storage/StorageItems/ZipStorageFolder.cs#L558-L594","documentation":"ZipStorageFolder.DeleteAsync throws NotSupportedException(\"Moving to recycle bin is not supported.\") under the same narrow condition as the file version: deleting the archive root (Path == containerPath) with a non-permanent option (recycle bin) and no backingFile. The recycle-bin API needs a real shell-backed file; a path-only zip root cannot be recycled. Permanent deletes and deletes with a backingFile are handled.","triggerScenarios":"Deleting a ZipStorageFolder that is the archive container (Path == containerPath), no backingFile, with StorageDeleteOption.Default (recycle bin).","commonSituations":"User presses Delete (no Shift) on a .zip opened by path with no StorageFile backing, sending it to recycle bin.","solutions":["Delete with StorageDeleteOption.PermanentDelete, or construct the ZipStorageFolder with a backingFile so the backing file's DeleteAsync is used.","At the call site, detect zip-root + no backing file and resolve the StorageFile first or switch to permanent delete.","Use the ZipStorageFolder(BaseStorageFile) constructor for archive roots that must support recycle-bin deletes."],"exampleFix":"// before\nawait zipRootFolder.DeleteAsync(); // recycle bin, throws\n\n// after\nawait zipRootFolder.DeleteAsync(StorageDeleteOption.PermanentDelete);","handlingStrategy":"validation","validationCode":"bool CanRecycle(BaseStorageFolder f) => !(f is ZipStorageFolder zsf && zsf.Path == /*containerPath*/ /*&& no backingFile*/);","typeGuard":"static bool IsZipBacked(BaseStorageFolder f) => f is ZipStorageFolder;","tryCatchPattern":"try { await f.DeleteAsync(); }\ncatch (NotSupportedException) { await f.DeleteAsync(StorageDeleteOption.PermanentDelete); }","preventionTips":["Use the ZipStorageFolder(BaseStorageFile) constructor to support recycle-bin deletes.","Fall back to PermanentDelete for path-only roots.","Detect root archives without backing files before default delete."],"tags":["winrt","storage","zip","delete","folder","recycle-bin","not-supported"],"backgroundTag":null,"analyzedSha":"68c68a58d4d6a5f7197e07c8fff85cfd4279c78b","analyzedAt":"2026-08-13T10:34:54.614Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}