{"record":{"id":"342ad984f3211669","repo":"JosefNemec/Playnite","slug":"cannot-create-game-from-executable-path-not-fou","errorCode":null,"errorMessage":"Cannot create game from executable, {path} not found.","messagePattern":"Cannot create game from executable, (.+?) not found\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"source/Playnite/Extensions/GameExtensions.cs","lineNumber":62,"sourceCode":"            expaded.TrackingPath = game.ExpandVariables(expaded.TrackingPath, true);\r\n            if (expaded.Type != GameActionType.URL)\r\n            {\r\n                expaded.Path = game.ExpandVariables(expaded.Path, true);\r\n            }\r\n\r\n            return expaded;\r\n        }\r\n    }\r\n\r\n    public static class GameExtensions\r\n    {\r\n        private static ILogger logger = LogManager.GetLogger();\r\n\r\n        public static Game GetGameFromExecutable(string path)\r\n        {\r\n            if (!File.Exists(path))\r\n            {\r\n                throw new FileNotFoundException($\"Cannot create game from executable, {path} not found.\");\r\n            }\r\n\r\n            var game = new Game();\r\n            if (string.Equals(Path.GetExtension(path), \".lnk\", StringComparison.OrdinalIgnoreCase))\r\n            {\r\n                var prog = Programs.GetLnkShortcutData(path);\r\n                var fileInfo = new FileInfo(prog.Path);\r\n                if (!fileInfo.Exists && prog.Path.Contains(\"Program Files (x86)\"))\r\n                {\r\n                    var newPath = prog.Path.Replace(\"Program Files (x86)\", \"Program Files\");\r\n                    if (File.Exists(newPath))\r\n                    {\r\n                        fileInfo = new FileInfo(newPath);\r\n                        if (prog.WorkDir.Contains(\"Program Files (x86)\"))\r\n                        {\r\n                            prog.WorkDir.Replace(\"Program Files (x86)\", \"Program Files\");\r\n                        }\r\n                    }\r","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Extensions/GameExtensions.cs#L44-L80","documentation":"Thrown as FileNotFoundException by GetGameFromExecutable when File.Exists(path) is false. The method reads .lnk/.url/.exe metadata from the file, so a non-existent path cannot be processed. This is a precondition check before any file I/O.","triggerScenarios":"Calling GameExtensions.GetGameFromExecutable(path) where path does not point to an existing file — wrong path, deleted executable, or an unresolved shortcut target recorded before validation.","commonSituations":"Importing a game from a shortcut whose target was moved/uninstalled; path stored with a relative or environment-variable value that resolves differently; race where the file was deleted between selection and import.","solutions":["Check File.Exists(path) before calling GetGameFromExecutable.","Resolve and normalize the path (full path, expanded env vars) before the call.","If importing shortcuts, validate the shortcut target exists and prompt the user to re-locate if missing."],"exampleFix":"// before\nif (!File.Exists(path)) { throw new FileNotFoundException($\"Cannot create game from executable, {path} not found.\"); }\n\n// after — guard at call site\nif (!File.Exists(path)) {\n    logger.Warn($\"Executable not found: {path}\");\n    return null;\n}\nvar game = GameExtensions.GetGameFromExecutable(path);","handlingStrategy":"validation","validationCode":"// Check file existence before importing.\nif (!File.Exists(path)) { logger.Warn($\"Executable missing: {path}\"); return null; }","typeGuard":null,"tryCatchPattern":"try { var game = GameExtensions.GetGameFromExecutable(path); }\ncatch (FileNotFoundException) { logger.Warn($\"Executable not found: {path}\"); }","preventionTips":["Resolve and expand paths fully before the import call.","When importing shortcuts, validate the target exists and offer re-location.","Cache existence checks for batch imports to avoid repeated disk hits."],"tags":["filesystem","game-import","precondition","null-check"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}