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 Themes.CopyThemeDirectory when sourceDirName does not exist. A DirectoryInfo is created for the path and `dir.Exists` is checked before any copy; a missing source yields DirectoryNotFoundException. This routine is used internally when scaffolding and updating themes, so a wrong source (often the bundled Default theme path) propagates upward.
Source
Thrown at source/Tools/Playnite.Toolbox/Themes.cs:117
Path = changePath
});
}
}
return changes;
}
public static List<FileChange> GetThemeChangelog(Version baseVersion, ApplicationMode mode)
{
return GetThemeChangelog(baseVersion, mode, Paths.ChangeLogsDir);
}
public static void CopyThemeDirectory(string sourceDirName, string destDirName, List<string> approvedXamls)
{
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 (var file in files)
{
string temppath = Path.Combine(destDirName, file.Name);
if (file.Extension.Equals(".xaml", StringComparison.OrdinalIgnoreCase))
{
if (approvedXamls.ContainsString(file.FullName))
{
View on GitHub (pinned to 5911f4e964)
Solutions
- Verify the source directory exists with `Directory.Exists(sourceDirName)` before calling; log the resolved absolute path.
- Ensure the Default theme template folder for the requested ApplicationMode is present under Paths.GetThemesPath(mode).
- Re-deploy the Toolbox Templates/Themes tree so the Default source is available.
- Pass absolute paths; avoid relying on CWD for theme template roots.
Example fix
// before
Themes.CopyThemeDirectory(@"Themes\Default", outDir, approved);
// after
var src = Path.Combine(Paths.GetThemesPath(mode), "Default");
if (!Directory.Exists(src))
throw new DirectoryNotFoundException($"Source theme missing: {src}");
Themes.CopyThemeDirectory(src, outDir, approved); Defensive patterns
Strategy: validation
Validate before calling
if (!Directory.Exists(sourceDirName))
throw new DirectoryNotFoundException($"Source theme directory not found: {sourceDirName}"); Prevention
- Resolve theme template roots (e.g. the Default theme) to absolute paths and verify existence before copying.
- Ensure the Templates/Themes tree for the requested ApplicationMode is deployed.
- Treat a missing source as a packaging/deploy defect to fix at the source, not a runtime catch.
When it happens
Trigger: Calling CopyThemeDirectory with a sourceDirName that is misspelled, on a different drive, or not yet created. Internally: GenerateNewTheme copies from Paths.GetThemesPath(mode)/"Default"; if that Default theme folder is absent, this throws.
Common situations: Portable/extracted Toolbox lacking the Default theme templates; mode mismatch (requesting Fullscreen themes when only Desktop templates shipped); path case or separator issues on the Default theme source.
Related errors
- Theme changelog not found.
- Manifest file ({PlaynitePaths.ThemeManifestFileName}) not fo
- Cannot update theme that was not generated via Toolbox utili
- Theme directory "{outDir}" already exists.
- Manifest file ({PlaynitePaths.ExtensionManifestFileName}) no
AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13).
Data as JSON: /api/errors/1142df0f141cfbd7.
Report an issue: GitHub.