JosefNemec/Playnite · error · DirectoryNotFoundException
Source directory does not exist or could not be found: {sour
Error message
Source directory does not exist or could not be found: {sourceDirName} What it means
Thrown by FileSystem.CopyDirectory when the DirectoryInfo constructed from sourceDirName does not exist on disk. It is a DirectoryNotFoundException with the offending path embedded, surfaced before any files are copied.
Source
Thrown at source/Playnite/Common/FileSystem.cs:447
{
// Whitespace characters can cause confusion in methods, causing them to process
// the parent directory instead and causing an infinite loop
if (childDirectory.Name.IsNullOrWhiteSpace())
{
return false;
}
return true;
}
public static void CopyDirectory(string sourceDirName, string destDirName, bool copySubDirs = true, bool overwrite = true)
{
sourceDirName = Paths.FixPathLength(sourceDirName);
destDirName = Paths.FixPathLength(destDirName);
var dir = new DirectoryInfo(sourceDirName);
if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Source directory does not exist or could not be found: "
+ sourceDirName);
}
var dirs = dir.GetDirectories();
if (!Directory.Exists(destDirName))
{
Directory.CreateDirectory(destDirName);
}
var files = dir.GetFiles();
foreach (FileInfo file in files)
{
string temppath = Path.Combine(destDirName, file.Name);
file.CopyTo(temppath, overwrite);
}
if (copySubDirs)
View on GitHub (pinned to 5911f4e964)
Solutions
- Verify Directory.Exists(sourceDirName) before calling CopyDirectory.
- Check that the drive hosting the source is mounted and the path casing is correct.
- For network paths, confirm the share is online and credentials are cached.
- Log the exact source path to pinpoint typos or stale configuration.
Example fix
// before
FileSystem.CopyDirectory(src, dest);
// after — guard and report the missing source
if (!Directory.Exists(src))
{
logger.Warn($"Copy source missing, skipping: {src}");
return;
}
FileSystem.CopyDirectory(src, dest); Defensive patterns
Strategy: validation
Validate before calling
if (!Directory.Exists(sourceDirName)) throw new DirectoryNotFoundException(sourceDirName);
Try / catch
try { FileSystem.CopyDirectory(src, dest); }
catch (DirectoryNotFoundException ex) { logger.Warn(ex.Message); /* skip missing source */ } Prevention
- Validate Directory.Exists(source) before copying.
- Confirm the source drive/share is mounted before batch operations.
- Log the exact source path to catch typos in configuration.
When it happens
Trigger: Calling CopyDirectory with a source that was never created, was moved/deleted, lives on an unmounted drive, or whose path is mistyped; a UNC/network source that is currently unreachable; a source path that exceeds MAX_PATH after FixPathLength.
Common situations: Migrating or backing up a library whose install folder was removed by the platform (Steam/Epic uninstall); copying from a disconnected external drive; wrong casing/typo in a configured backup source path.
Related errors
- Root directory is not set or does not exist.
- Cannot add file to database, file not found.
- Backup output path not specified!
- No URL was given.
- Failed to read {path}
AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13).
Data as JSON: /api/errors/b99ce72abce30b96.
Report an issue: GitHub.