stride3d/stride · error · FileNotFoundException

File not found inside ZIP archive.

Error message

File not found inside ZIP archive.

What it means

ZipFileSystemProvider.OpenStream looks up the requested URL in the ZIP's entry table (zipFileEntries). When the entry is absent, a FileNotFoundException is thrown because the file does not exist inside the archive. The check happens before mode/access validation.

Solutions

  1. Check provider.FileExists(url) before calling OpenStream.
  2. Verify the URL exists in the archive (list entries via ListFiles) and match exact casing/path.
  3. Repackage/re-upload the ZIP ensuring the required entry is included.
  4. Wrap in try-catch FileNotFoundException to handle optional files gracefully.

Example fix

// before
using var s = zipProvider.OpenStream(url, VirtualFileMode.Open, VirtualFileAccess.Read);
// after
if (!zipProvider.FileExists(url))
    throw new FileNotFoundException($"{url} missing from ZIP archive.", url);
using var s = zipProvider.OpenStream(url, VirtualFileMode.Open, VirtualFileAccess.Read);
Defensive patterns

Strategy: validation

Validate before calling

if (!zipProvider.FileExists(url))
    throw new FileNotFoundException($"Entry '{url}' not present in ZIP archive.", url);

Try / catch

try { stream = zipProvider.OpenStream(url, VirtualFileMode.Open, VirtualFileAccess.Read); }
catch (FileNotFoundException) { stream = null; /* fall back to alternate source */ }

Prevention

When it happens

Trigger: Opening a stream for a URL that is not an entry in the ZIP: wrong path/casing, file missing from the archive, or the URL was never passed through the provider's own URL mapping (e.g. absolute local path instead of archive-relative).

Common situations: Corrupt or partially uploaded ZIP assets; file renamed in the archive but not in code; case-sensitive lookups failing on mixed-case URLs; loading bundled resources after a packaging step omitted the file.

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 stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/be2567ff0b32c641. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.IO/ZipFileSystemProvider.cs:65

        {
            if (!zipFileEntries.TryGetValue(path, out var zipFileEntry) || zipFileEntry.Method != Compression.Store)
            {
                filePath = null;
                start = 0;
                end = -1;
                return false;
            }

            filePath = zipFile.FileName;
            start = zipFileEntry.FileOffset;
            end = zipFileEntry.FileOffset + zipFileEntry.FileSize;
            return true;
        }

        public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamType = StreamFlags.None)
        {
            if (!zipFileEntries.TryGetValue(url, out var zipFileEntry))
                throw new FileNotFoundException("File not found inside ZIP archive.");

            if (mode != VirtualFileMode.Open || access != VirtualFileAccess.Read)
                throw new UnauthorizedAccessException("ZIP archive are read-only.");

            lock (zipFile)
            {
                if (zipFileEntry.Method == Compression.Store)
                {
                    // Open a VirtualFileStream on top of Zip FileStream
                    return new VirtualFileStream(new FileStream(zipFileEntry.ZipFileName, FileMode.Open, FileAccess.Read), zipFileEntry.FileOffset, zipFileEntry.FileOffset + zipFileEntry.FileSize);
                }

                // Decompress it into a MemoryStream
                var buffer = new byte[zipFileEntry.FileSize];
                zipFile.ExtractFile(zipFileEntry, buffer);
                return new MemoryStream(buffer);
            }
        }

View on GitHub (pinned to 96fad776d2)