{"record":{"id":"047215f85c6bdaf0","repo":"Sonarr/Sonarr","slug":"unable-to-create-the-folder-destinationfolder","errorCode":null,"errorMessage":"Unable to create the folder '{destinationFolder}' in the recycling bin for the file '{fileInfo.Name}'","messagePattern":"Unable to create the folder '(.+?)' in the recycling bin for the file '(.+?)'","errorType":"exception","errorClass":"RecycleBinException","httpStatus":null,"severity":"error","filePath":"src/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs","lineNumber":103,"sourceCode":"                _logger.Debug(\"File has been permanently deleted: {0}\", path);\n\n                return null;\n            }\n            else\n            {\n                var fileInfo = new FileInfo(path);\n                var destinationFolder = Path.Combine(recyclingBin, subfolder);\n                var destination = Path.Combine(destinationFolder, fileInfo.Name);\n\n                try\n                {\n                    _logger.Debug(\"Creating folder {0}\", destinationFolder);\n                    _diskProvider.CreateFolder(destinationFolder);\n                }\n                catch (IOException e)\n                {\n                    _logger.Error(e, \"Unable to create the folder '{0}' in the recycling bin for the file '{1}'\", destinationFolder, fileInfo.Name);\n                    throw new RecycleBinException($\"Unable to create the folder '{destinationFolder}' in the recycling bin for the file '{fileInfo.Name}'\", e);\n                }\n\n                var index = 1;\n                while (_diskProvider.FileExists(destination))\n                {\n                    index++;\n                    if (fileInfo.Extension.IsNullOrWhiteSpace())\n                    {\n                        destination = Path.Combine(destinationFolder, fileInfo.Name + \"_\" + index);\n                    }\n                    else\n                    {\n                        destination = Path.Combine(destinationFolder, Path.GetFileNameWithoutExtension(fileInfo.Name) + \"_\" + index + fileInfo.Extension);\n                    }\n                }\n\n                try\n                {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/Sonarr/Sonarr/blob/da2284d7eaab22ed9b2ca698af690148d691e967/src/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs#L85-L121","documentation":"RecycleBinException (a DirectoryNotFoundException subclass) thrown when CreateFolder for the recycle-bin destination subfolder raises IOException. Preserves the inner IOException so callers can inspect the real OS error.","triggerScenarios":"DeleteFile is asked to move a file into the recycle bin under a subfolder (relative path of the original); creating Path.Combine(recyclingBin, subfolder) fails with IOException.","commonSituations":"Recycle bin path on a read-only volume; invalid characters in the subfolder; insufficient permissions to create directories; recycle bin root doesn't exist and parent isn't creatable; disk full.","solutions":["Check Sonarr has create-directory permission on the configured recycle bin root.","Confirm the recycle bin path exists and is on a writable volume with free space.","Sanitize the subfolder for invalid path characters before combining.","If the recycle bin is unavailable, disable 'Use Recycle Bin' to delete directly."],"exampleFix":"// before\n_diskProvider.CreateFolder(destinationFolder);\n\n// after: ensure parent exists, then create\n_diskProvider.CreateFolder(_diskProvider.GetParentFolder(destinationFolder));\n_diskProvider.CreateFolder(destinationFolder);","handlingStrategy":"validation","validationCode":"var dest = Path.Combine(recyclingBin, subfolder);\nvar parent = _diskProvider.GetParentFolder(dest);\nif (!_diskProvider.FolderExists(parent))\n    _diskProvider.CreateFolder(parent);\n// now safe to CreateFolder(dest)","typeGuard":null,"tryCatchPattern":"try { _recycleBinProvider.DeleteFile(path, subfolder); }\ncatch (RecycleBinException ex) when (ex.InnerException is IOException)\n{ _logger.Error(ex, \"Recycle bin folder creation failed\"); /* alert ops */ }","preventionTips":["Configure the recycle bin on a writable, persistent volume.","Run Sonarr with directory-create permission on the recycle bin root.","Sanitize subfolder strings for invalid path characters."],"tags":["recycle-bin","filesystem","io","directory","deletion"],"backgroundTag":null,"analyzedSha":"da2284d7eaab22ed9b2ca698af690148d691e967","analyzedAt":"2026-08-13T15:53:02.562Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}