babalae/better-genshin-impact · error · FileNotFoundException
未找到{featName}的素材文件夹
Error message
未找到{featName}的素材文件夹 What it means
Thrown by GameTaskManager.LoadAssetImage when neither a resolution-specific Assets folder (e.g. 2560x1440) nor the fallback 1920x1080 folder exists for the given task feature name. The method first tries a folder matching the actual game screen size, then falls back to 1920x1080. If both are absent, the FileNotFoundException fires, halting asset loading for that task.
Source
Thrown at BetterGenshinImpact/GameTask/GameTaskManager.cs:164
return LoadAssetImage(featName, assertName, TaskContext.Instance().SystemInfo, flags);
}
/// <summary>
/// 获取素材图片并缩放
/// </summary>
/// <returns></returns>
/// <exception cref="FileNotFoundException"></exception>
public static Mat LoadAssetImage(string featName, string assertName, ISystemInfo systemInfo, ImreadModes flags = ImreadModes.Color)
{
var assetsFolder = Global.Absolute($@"GameTask\{featName}\Assets\{systemInfo.GameScreenSize.Width}x{systemInfo.GameScreenSize.Height}");
if (!Directory.Exists(assetsFolder))
{
assetsFolder = Global.Absolute($@"GameTask\{featName}\Assets\1920x1080");
}
if (!Directory.Exists(assetsFolder))
{
throw new FileNotFoundException($"未找到{featName}的素材文件夹");
}
var filePath = Path.Combine(assetsFolder, assertName);
if (!File.Exists(filePath))
{
throw new FileNotFoundException($"未找到{featName}中的{assertName}文件");
}
var mat = Mat.FromStream(File.OpenRead(filePath), flags);
if (systemInfo.GameScreenSize.Width != 1920)
{
mat = ResizeHelper.Resize(mat, systemInfo.AssetScale);
}
return mat;
}
/// <summary>View on GitHub (pinned to a7cb36712d)
Solutions
- Verify the directory GameTask\{featName}\Assets\1920x1080 exists relative to Global.Absolute — create it or restore it from source control.
- Check that featName passed to LoadAssetImage exactly matches the folder name on disk (case-sensitive on some file systems).
- If running from a published build, ensure the build/publish step copies the Assets folder into the output directory.
- Add a Directory.Exists pre-check before calling LoadAssetImage and log the resolved absolute path for easier diagnosis.
Example fix
// before
var assetsFolder = Global.Absolute($@"GameTask\{featName}\Assets\1920x1080");
if (!Directory.Exists(assetsFolder))
throw new FileNotFoundException($"未找到{featName}的素材文件夹");
// after — log resolved path so the caller can diagnose
if (!Directory.Exists(assetsFolder))
throw new FileNotFoundException(
$"未找到{featName}的素材文件夹,期望路径:{assetsFolder}", assetsFolder); Defensive patterns
Strategy: validation
Validate before calling
// Check before calling LoadAssetImage
var fallbackFolder = Global.Absolute($@"GameTask\{featName}\Assets\1920x1080");
if (!Directory.Exists(fallbackFolder))
{
logger.LogError("素材文件夹不存在:{Path}", fallbackFolder);
return; // or skip task
} Try / catch
try { var mat = GameTaskManager.LoadAssetImage(featName, name, systemInfo); }
catch (FileNotFoundException ex) { logger.LogError(ex, "素材加载失败:{FeatName}", featName); /* skip or fallback */ } Prevention
- Always include Assets directories in version control or build output.
- Use consistent featName constants rather than string literals.
- Add a startup check that verifies all required Assets folders exist.
When it happens
Trigger: Calling LoadAssetImage(featName, ...) where featName maps to a GameTask\{featName}\Assets directory that does not exist on disk. This happens when featName is misspelled, the task folder was never shipped, or a clean/partial build omitted the Assets directory.
Common situations: Running the app from a non-standard working directory where Global.Absolute resolves to a path without the Assets tree; cloning the repo without pulling large asset files (LFS); renaming or refactoring a task folder name without updating the featName callers.
Related errors
- 未找到{featName}中的{assertName}文件
- 未找到{taskName}的素材文件夹
- 未找到{taskName}中的{assetName}文件
- javaScript不能为空
- maxNumToCheck不能为空
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/7b76b00f1dada56e.
Report an issue: GitHub.