LorisYounger/VPet · error · FileNotFoundException

Can not find file

Error message

Can not find file: {Path}

What it means

APNGAnimation throws FileNotFoundException in its async load routine when the animation image path does not exist on disk. Before parsing, it explicitly checks File.Exists(Path) and fails fast with the path embedded in the message. This guards the parser from opening a nonexistent file.

Solutions

  1. Verify the file at Path exists before constructing APNGAnimation (File.Exists).
  2. Fix the path to be absolute or rooted against ExtensionValue.BaseDirectory instead of the process working directory.
  3. Reinstall/restore the missing animation asset.
  4. Check file name casing and extension on case-sensitive deployments.

Example fix

// before
new APNGAnimation("bg/anm_01.png");
// after
var path = Path.Combine(baseDir, "bg", "anm_01.png");
if (File.Exists(path)) new APNGAnimation(path);
Defensive patterns

Strategy: validation

Validate before calling

if (!File.Exists(path)) throw new FileNotFoundException($"APNG asset missing: {path}");

Try / catch

try { var anim = new APNGAnimation(path); } catch (FileNotFoundException ex) { Log.Warn($"missing animation: {ex.FileName}"); /* fallback to static picture */ }

Prevention

When it happens

Trigger: Calling the APNGAnimation public constructor / load with a Path that does not resolve to an existing file at load time, e.g. a missing texture in the game's Graph directory.

Common situations: Asset missing from install/pack, wrong working directory (relative paths resolved against the exe, not the expected folder), renamed or case-mismatched file names, save/mod loaders pointing at a deleted custom animation.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of LorisYounger/VPet@ffb9cc2a85 (2026-09-15). Data as JSON: /api/errors/d3c3d2137c0b6538. Report an issue: GitHub.

Appendix: source

Thrown at VPet-Simulator.Core/Graph/APNGAnimation.cs:113

            if (!(path is FileInfo file) || path.Extension.ToLowerInvariant() != ".png")
                return;

            bool isLoop = info[(gbol)"loop"];
            APNGAnimation pa = new APNGAnimation(graph, file.FullName, new GraphInfo(path, info), isLoop);
            graph.AddGraph(pa);
        }

        private async Task startup()
        {
            while (Function.MemoryUsage() > PNGAnimation.MaxLoadMemory)
            {
                await Task.Delay(100);
            }

            try
            {
                if (!File.Exists(Path))
                    throw new FileNotFoundException($"Can not find file: {Path}");

                IsReady = false;
                IsFail = false;
                FailMessage = "";

                var parsed = ParseApng(Path);
                if (parsed.Frames.Count == 0)
                    throw new InvalidDataException("No APNG frames found.");

                FrameWidth = parsed.CanvasWidth;
                FrameHeight = parsed.CanvasHeight;
                if (FrameWidth > GraphCore.Resolution)
                {
                    FrameWidth = GraphCore.Resolution;
                    FrameHeight = (int)(FrameHeight * (GraphCore.Resolution / (double)parsed.CanvasWidth));
                }
                if (parsed.Frames.Count * FrameWidth >= 60000)
                {

View on GitHub (pinned to ffb9cc2a85)