{"record":{"id":"b99ce72abce30b96","repo":"JosefNemec/Playnite","slug":"source-directory-does-not-exist-or-could-not-be-fo","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/Playnite/Common/FileSystem.cs","lineNumber":447,"sourceCode":"        {\r\n            // Whitespace characters can cause confusion in methods, causing them to process\r\n            // the parent directory instead and causing an infinite loop\r\n            if (childDirectory.Name.IsNullOrWhiteSpace())\r\n            {\r\n                return false;\r\n            }\r\n\r\n            return true;\r\n        }\r\n\r\n        public static void CopyDirectory(string sourceDirName, string destDirName, bool copySubDirs = true, bool overwrite = true)\r\n        {\r\n            sourceDirName = Paths.FixPathLength(sourceDirName);\r\n            destDirName = Paths.FixPathLength(destDirName);\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 (FileInfo file in files)\r\n            {\r\n                string temppath = Path.Combine(destDirName, file.Name);\r\n                file.CopyTo(temppath, overwrite);\r\n            }\r\n\r\n            if (copySubDirs)\r","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Common/FileSystem.cs#L429-L465","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nFileSystem.CopyDirectory(src, dest);\n\n// after — guard and report the missing source\nif (!Directory.Exists(src))\n{\n    logger.Warn($\"Copy source missing, skipping: {src}\");\n    return;\n}\nFileSystem.CopyDirectory(src, dest);","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(sourceDirName)) throw new DirectoryNotFoundException(sourceDirName);","typeGuard":null,"tryCatchPattern":"try { FileSystem.CopyDirectory(src, dest); }\ncatch (DirectoryNotFoundException ex) { logger.Warn(ex.Message); /* skip missing source */ }","preventionTips":["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."],"tags":["filesystem","directory","validation","playnite"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}