JosefNemec/Playnite · error · FileNotFoundException
Cannot create game from executable, {path} not found.
Error message
Cannot create game from executable, {path} not found. What it means
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.
Source
Thrown at source/Playnite/Extensions/GameExtensions.cs:62
expaded.TrackingPath = game.ExpandVariables(expaded.TrackingPath, true);
if (expaded.Type != GameActionType.URL)
{
expaded.Path = game.ExpandVariables(expaded.Path, true);
}
return expaded;
}
}
public static class GameExtensions
{
private static ILogger logger = LogManager.GetLogger();
public static Game GetGameFromExecutable(string path)
{
if (!File.Exists(path))
{
throw new FileNotFoundException($"Cannot create game from executable, {path} not found.");
}
var game = new Game();
if (string.Equals(Path.GetExtension(path), ".lnk", StringComparison.OrdinalIgnoreCase))
{
var prog = Programs.GetLnkShortcutData(path);
var fileInfo = new FileInfo(prog.Path);
if (!fileInfo.Exists && prog.Path.Contains("Program Files (x86)"))
{
var newPath = prog.Path.Replace("Program Files (x86)", "Program Files");
if (File.Exists(newPath))
{
fileInfo = new FileInfo(newPath);
if (prog.WorkDir.Contains("Program Files (x86)"))
{
prog.WorkDir.Replace("Program Files (x86)", "Program Files");
}
}
View on GitHub (pinned to 5911f4e964)
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.
Example fix
// before
if (!File.Exists(path)) { throw new FileNotFoundException($"Cannot create game from executable, {path} not found."); }
// after — guard at call site
if (!File.Exists(path)) {
logger.Warn($"Executable not found: {path}");
return null;
}
var game = GameExtensions.GetGameFromExecutable(path); Defensive patterns
Strategy: validation
Validate before calling
// Check file existence before importing.
if (!File.Exists(path)) { logger.Warn($"Executable missing: {path}"); return null; } Try / catch
try { var game = GameExtensions.GetGameFromExecutable(path); }
catch (FileNotFoundException) { logger.Warn($"Executable not found: {path}"); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Can't scan emulation directory, {directory} doesn't exist.
- URL file doesn't have shortcut definition section.
- Manifest file ({PlaynitePaths.ExtensionManifestFileName}) no
- Theme changelog not found.
- Source directory does not exist or could not be found: {sour
AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13).
Data as JSON: /api/errors/342ad984f3211669.
Report an issue: GitHub.