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

  1. Verify the source directory exists with `Directory.Exists(sourceDirName)` before calling; log the resolved absolute path.
  2. Ensure the Default theme template folder for the requested ApplicationMode is present under Paths.GetThemesPath(mode).
  3. Re-deploy the Toolbox Templates/Themes tree so the Default source is available.
  4. 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

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


AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13). Data as JSON: /api/errors/1142df0f141cfbd7. Report an issue: GitHub.