{"record":{"id":"677ebc31ad4b11a5","repo":"files-community/Files","slug":"moving-to-recycle-bin-is-not-supported","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/ZipStorageFile.cs","lineNumber":567,"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 < 0)\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\tawait compressor.ModifyArchiveAsync(archiveStream, new Dictionary<int, string>() { { index, null } }, Credentials.Password, ms);\n\t\t\t\t\t\t}","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/files-community/Files/blob/68c68a58d4d6a5f7197e07c8fff85cfd4279c78b/src/Files.App/Utils/Storage/StorageItems/ZipStorageFile.cs#L549-L585","documentation":"ZipStorageFile.DeleteAsync throws NotSupportedException(\"Moving to recycle bin is not supported.\") only when deleting the archive root (Path == containerPath) with a non-permanent delete option (i.e. StorageDeleteOption.Default, which sends to recycle bin) and there is no backingFile. The recycle bin API needs a real filesystem shell item; a path-only zip root without a backing file cannot be recycled. Permanent deletes (and any delete that has a backingFile) are handled.","triggerScenarios":"Deleting a ZipStorageFile that is the archive container itself (Path == containerPath), with no backingFile, using the default delete option (StorageDeleteOption.Default == recycle bin).","commonSituations":"A user presses Delete (not Shift+Delete) on a .zip file that was opened directly by path (no StorageFile backing), so the code requests a recycle-bin delete.","solutions":["Use StorageDeleteOption.PermanentDelete when deleting the path-only zip root, or provide a backingFile so backingFile.DeleteAsync() is used.","Construct the ZipStorageFile via the overload that takes a BaseStorageFile backingFile so recycle-bin deletes route through the backing file.","At the call site, detect zip-root + no backing file and switch to permanent delete or resolve the StorageFile first."],"exampleFix":"// before\nawait zipRootFile.DeleteAsync(); // default == recycle bin, throws for path-only root\n\n// after\nawait zipRootFile.DeleteAsync(StorageDeleteOption.PermanentDelete);","handlingStrategy":"validation","validationCode":"bool CanRecycle(BaseStorageFile f) => !(f is ZipStorageFile zsf && zsf.Path == /*containerPath*/ /*&& no backingFile*/);","typeGuard":"static bool IsZipRootByPath(BaseStorageFile f) => f is ZipStorageFile zsf && zsf.Path == typeof(ZipStorageFile).GetField(\"containerPath\", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(f) as string;","tryCatchPattern":"try { await f.DeleteAsync(); }\ncatch (NotSupportedException) { await f.DeleteAsync(StorageDeleteOption.PermanentDelete); }","preventionTips":["Construct ZipStorageFile with a backingFile when recycle-bin delete is required.","Use StorageDeleteOption.PermanentDelete for path-only zip roots.","Detect root archives without backing files before default delete."],"tags":["winrt","storage","zip","delete","recycle-bin","not-supported"],"backgroundTag":null,"analyzedSha":"68c68a58d4d6a5f7197e07c8fff85cfd4279c78b","analyzedAt":"2026-08-13T10:34:54.614Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}