babalae/better-genshin-impact · error · DirectoryNotFoundException
脚本文件夹不存在:{ProjectPath}
Error message
脚本文件夹不存在:{ProjectPath} What it means
Thrown by the ScriptProject constructor when the project directory at Path.Combine(Global.ScriptPath(), folderName) does not exist. This is a DirectoryNotFoundException — the script folder referenced by FolderName is not present in the scripts directory. This is the first check in the constructor, before manifest loading.
Source
Thrown at BetterGenshinImpact/Core/Script/Project/ScriptProject.cs:35
namespace BetterGenshinImpact.Core.Script.Project;
public class ScriptProject
{
public string ProjectPath { get; set; }
public string ManifestFile { get; set; }
public Manifest Manifest { get; set; }
public string FolderName { get; set; }
public ScriptProject(string folderName)
{
FolderName = folderName;
ProjectPath = Path.Combine(Global.ScriptPath(), folderName);
if (!Directory.Exists(ProjectPath))
{
throw new DirectoryNotFoundException("脚本文件夹不存在:" + ProjectPath);
}
ManifestFile = Path.GetFullPath(Path.Combine(ProjectPath, "manifest.json"));
if (!File.Exists(ManifestFile))
{
throw new FileNotFoundException("manifest.json文件不存在,请确认此脚本是JS脚本类型。" + ManifestFile);
}
Manifest = Manifest.FromJson(File.ReadAllText(ManifestFile));
Manifest.Validate(ProjectPath);
}
public ScrollViewer? LoadSettingUi(dynamic context)
{
var settingItems = Manifest.LoadSettingItems(ProjectPath);
if (settingItems.Count == 0)
{
return null;View on GitHub (pinned to a7cb36712d)
Solutions
- Verify the folder exists under the scripts directory: check the path in the error message.
- Ensure the FolderName in the ScriptGroupProject matches the actual folder name exactly (including case).
- Re-download or reinstall the script package if the folder is missing.
- Remove the orphaned ScriptGroupProject entry from the configuration if the script is no longer needed.
Defensive patterns
Strategy: validation
Validate before calling
string projectPath = Path.Combine(Global.ScriptPath(), folderName);
if (!Directory.Exists(projectPath))
throw new DirectoryNotFoundException($"Script folder not found: {projectPath}"); Type guard
static bool IsScriptFolderValid(string folderName)
{
var path = Path.Combine(Global.ScriptPath(), folderName);
return Directory.Exists(path);
} Try / catch
try
{
var project = new ScriptProject(folderName);
}
catch (DirectoryNotFoundException ex)
{
TaskControl.Logger.LogError("Script folder missing: {Message}", ex.Message);
// Skip or prompt user to reinstall
} Prevention
- Verify script folders exist before constructing ScriptProject.
- Keep FolderName in configuration consistent with actual folder names.
- Handle orphaned configuration entries gracefully.
When it happens
Trigger: Constructing new ScriptProject(folderName) where the directory Global.ScriptPath()/folderName does not exist on disk. Called from ScriptGroupProject.BuildScriptProjectRelation when FolderName is set.
Common situations: A script group configuration references a folder name that was deleted, renamed, or never downloaded. The folder name in config doesn't match the actual folder on disk (typo, case mismatch). Scripts directory was moved or cleared.
Related errors
- manifest.json: name is required.
- manifest.json: version is required.
- manifest.json: main script is required.
- manifest.json文件不存在,请确认此脚本是JS脚本类型。{ManifestFile}
- 预热图片未找到: {modelType.PreHeatImagePath}
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/43cbc570f60de05c.
Report an issue: GitHub.