{"record":{"id":"1142df0f141cfbd7","repo":"JosefNemec/Playnite","slug":"source-directory-does-not-exist-or-could-not-be-fo-1142df","errorCode":null,"errorMessage":"Source directory does not exist or could not be found: {sourceDirName}","messagePattern":"Source directory does not exist or could not be found: (.+?)","errorType":"exception","errorClass":"DirectoryNotFoundException","httpStatus":null,"severity":"error","filePath":"source/Tools/Playnite.Toolbox/Themes.cs","lineNumber":117,"sourceCode":"                        Path = changePath\r\n                    });\r\n                }\r\n            }\r\n\r\n            return changes;\r\n        }\r\n\r\n        public static List<FileChange> GetThemeChangelog(Version baseVersion, ApplicationMode mode)\r\n        {\r\n            return GetThemeChangelog(baseVersion, mode, Paths.ChangeLogsDir);\r\n        }\r\n\r\n        public static void CopyThemeDirectory(string sourceDirName, string destDirName, List<string> approvedXamls)\r\n        {\r\n            var dir = new DirectoryInfo(sourceDirName);\r\n            if (!dir.Exists)\r\n            {\r\n                throw new DirectoryNotFoundException(\r\n                    \"Source directory does not exist or could not be found: \"\r\n                    + sourceDirName);\r\n            }\r\n\r\n            var dirs = dir.GetDirectories();\r\n            if (!Directory.Exists(destDirName))\r\n            {\r\n                Directory.CreateDirectory(destDirName);\r\n            }\r\n\r\n            var files = dir.GetFiles();\r\n            foreach (var file in files)\r\n            {\r\n                string temppath = Path.Combine(destDirName, file.Name);\r\n                if (file.Extension.Equals(\".xaml\", StringComparison.OrdinalIgnoreCase))\r\n                {\r\n                    if (approvedXamls.ContainsString(file.FullName))\r\n                    {\r","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Tools/Playnite.Toolbox/Themes.cs#L99-L135","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nThemes.CopyThemeDirectory(@\"Themes\\Default\", outDir, approved);\n\n// after\nvar src = Path.Combine(Paths.GetThemesPath(mode), \"Default\");\nif (!Directory.Exists(src))\n    throw new DirectoryNotFoundException($\"Source theme missing: {src}\");\nThemes.CopyThemeDirectory(src, outDir, approved);","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(sourceDirName))\n    throw new DirectoryNotFoundException($\"Source theme directory not found: {sourceDirName}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["themes","toolbox","filesystem","precondition"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}