{"record":{"id":"159197a24b3885ae","repo":"JosefNemec/Playnite","slug":"directory-not-found","errorCode":null,"errorMessage":"{directory} not found.","messagePattern":"(.+?) not found\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/Emulators/Emulation.cs","lineNumber":210,"sourceCode":"        }\r\n\r\n        public static bool IsEmuProfileValid(SDK.Models.Emulator emulator, string profileId)\r\n        {\r\n            if (profileId.StartsWith(SDK.Models.CustomEmulatorProfile.ProfilePrefix))\r\n            {\r\n                return emulator.CustomProfiles?.Any(a => a.Id == profileId) == true;\r\n            }\r\n            else\r\n            {\r\n                return GetProfile(emulator.BuiltInConfigId, profileId) != null;\r\n            }\r\n        }\r\n\r\n        public static string GetExecutable(string directory, EmulatorDefinitionProfile profile, bool relative)\r\n        {\r\n            if (!Directory.Exists(directory))\r\n            {\r\n                throw new Exception($\"{directory} not found.\");\r\n            }\r\n\r\n            var fileEnumerator = new SafeFileEnumerator(directory, \"*.*\", SearchOption.AllDirectories);\r\n            foreach (var file in fileEnumerator)\r\n            {\r\n                if (file.Attributes.HasFlag(FileAttributes.Directory))\r\n                {\r\n                    continue;\r\n                }\r\n\r\n                var relativePath = file.FullName.Replace(Path.GetDirectoryName(file.FullName), \"\").Trim(Path.DirectorySeparatorChar);\r\n                var regex = new Regex(profile.StartupExecutable, RegexOptions.IgnoreCase);\r\n                if (regex.IsMatch(relativePath))\r\n                {\r\n                    if (relative)\r\n                    {\r\n                        return relativePath;\r\n                    }\r","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Emulators/Emulation.cs#L192-L228","documentation":"Thrown as a generic Exception by Emulation.GetExecutable when the directory parameter does not exist on the filesystem. GetExecutable recursively enumerates files in the directory to match against the emulator profile's StartupExecutable regex, so a non-existent directory is a hard precondition failure.","triggerScenarios":"Calling Emulation.GetExecutable(directory, profile, relative) where Directory.Exists(directory) is false. The directory parameter is typically emulator.InstallDir, which may be unset, stale, or point to an uninstalled/moved emulator.","commonSituations":"The emulator was uninstalled but its InstallDir in Playnite still points to the old location. The emulator is on a removable drive or network share that is not currently mounted. The InstallDir was never set correctly (empty string or default placeholder). The emulator was moved to a different folder manually.","solutions":["Verify the emulator's InstallDir in Playnite emulator settings points to a valid existing directory.","If the emulator is on a removable/network drive, ensure it is connected before launching games.","Re-detect the emulator install location using Playnite's emulator configuration wizard.","If the emulator is no longer installed, reinstall it or update the InstallDir.","Add a Directory.Exists check before calling GetExecutable in custom code."],"exampleFix":"// before — calling GetExecutable without verifying directory\nvar exe = Emulation.GetExecutable(emulator.InstallDir, profile, true); // throws if dir missing\n\n// after — validate first\nif (!Directory.Exists(emulator.InstallDir))\n{\n    logger.Error($\"Emulator install directory not found: {emulator.InstallDir}\");\n    return null;\n}\nvar exe = Emulation.GetExecutable(emulator.InstallDir, profile, true);","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(emulator.InstallDir))\n{\n    logger.Error($\"Emulator install directory not found: {emulator.InstallDir}\");\n    return null;\n}","typeGuard":"static bool IsValidEmulatorDirectory(string directory)\n{\n    return !directory.IsNullOrEmpty() && Directory.Exists(directory);\n}","tryCatchPattern":null,"preventionTips":["Verify emulator InstallDir exists after every emulator configuration change.","Prompt users to re-detect the emulator if InstallDir is missing at launch time.","Store and validate emulator paths in the settings UI with a 'Browse' and 'Test' button."],"tags":["emulator","directory-not-found","executable-path","validation","filesystem"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}