Sonarr/Sonarr · error · RecycleBinException
Unable to create the folder '{destinationFolder}' in the rec
Error message
Unable to create the folder '{destinationFolder}' in the recycling bin for the file '{fileInfo.Name}' What it means
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.
Source
Thrown at src/NzbDrone.Core/MediaFiles/RecycleBinProvider.cs:103
_logger.Debug("File has been permanently deleted: {0}", path);
return null;
}
else
{
var fileInfo = new FileInfo(path);
var destinationFolder = Path.Combine(recyclingBin, subfolder);
var destination = Path.Combine(destinationFolder, fileInfo.Name);
try
{
_logger.Debug("Creating folder {0}", destinationFolder);
_diskProvider.CreateFolder(destinationFolder);
}
catch (IOException e)
{
_logger.Error(e, "Unable to create the folder '{0}' in the recycling bin for the file '{1}'", destinationFolder, fileInfo.Name);
throw new RecycleBinException($"Unable to create the folder '{destinationFolder}' in the recycling bin for the file '{fileInfo.Name}'", e);
}
var index = 1;
while (_diskProvider.FileExists(destination))
{
index++;
if (fileInfo.Extension.IsNullOrWhiteSpace())
{
destination = Path.Combine(destinationFolder, fileInfo.Name + "_" + index);
}
else
{
destination = Path.Combine(destinationFolder, Path.GetFileNameWithoutExtension(fileInfo.Name) + "_" + index + fileInfo.Extension);
}
}
try
{View on GitHub (pinned to da2284d7ea)
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.
Example fix
// before _diskProvider.CreateFolder(destinationFolder); // after: ensure parent exists, then create _diskProvider.CreateFolder(_diskProvider.GetParentFolder(destinationFolder)); _diskProvider.CreateFolder(destinationFolder);
Defensive patterns
Strategy: validation
Validate before calling
var dest = Path.Combine(recyclingBin, subfolder);
var parent = _diskProvider.GetParentFolder(dest);
if (!_diskProvider.FolderExists(parent))
_diskProvider.CreateFolder(parent);
// now safe to CreateFolder(dest) Try / catch
try { _recycleBinProvider.DeleteFile(path, subfolder); }
catch (RecycleBinException ex) when (ex.InnerException is IOException)
{ _logger.Error(ex, "Recycle bin folder creation failed"); /* alert ops */ } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unable to move '{path}' to the recycling bin: '{destination}
- Unable to delete episode file
- Directory doesn't exist. {path}
- File doesn't exist: {path}
- Source and destination can't be the same {0}
AI-assisted analysis of Sonarr/Sonarr@da2284d7ea (2026-08-13).
Data as JSON: /api/errors/047215f85c6bdaf0.
Report an issue: GitHub.