SubtitleEdit/subtitleedit · error · FileNotFoundException

Model file not found.

Error message

Model file not found.

What it means

Thrown by ImportCustomModel when the source path provided for a whisper.cpp custom model does not exist on disk (File.Exists returns false). This is the first validation in the import pipeline: existence check before extension and size validation.

Source

Thrown at src/ui/Features/Video/SpeechToText/Engines/WhisperEngineCpp.cs:141

    {
        var modelFileName = Path.Combine(GetAndCreateWhisperModelFolder(null), modelName);
        if (Extension.Length > 0 && !modelFileName.EndsWith(Extension))
        {
            modelFileName += Extension;
        }

        return modelFileName;
    }

    public bool SupportsCustomModels => true;

    public bool CustomModelIsFolder => false;

    public string ImportCustomModel(string sourcePath)
    {
        if (!File.Exists(sourcePath))
        {
            throw new FileNotFoundException("Model file not found.", sourcePath);
        }

        if (!sourcePath.EndsWith(".bin", StringComparison.OrdinalIgnoreCase))
        {
            throw new Exception("A whisper.cpp model must be a ggml '.bin' file.");
        }

        if (new FileInfo(sourcePath).Length < 10_000_000)
        {
            throw new Exception("The model file is too small (must be at least 10 MB) - is it really a whisper.cpp model?");
        }

        var destination = Path.Combine(GetAndCreateWhisperModelFolder(null), Path.GetFileName(sourcePath));
        File.Copy(sourcePath, destination, true);

        return Path.GetFileNameWithoutExtension(destination);
    }

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Use the file picker dialog to select the model file instead of typing a path.
  2. Verify the file exists at the specified path using the OS file explorer.
  3. Check file permissions — ensure the application has read access to the path.
  4. If using a network path, ensure the share is mounted and accessible.
  5. Copy the model file to a local directory before importing.
Defensive patterns

Strategy: validation

Validate before calling

// Validate before calling ImportCustomModel
if (!File.Exists(sourcePath))
    throw new FileNotFoundException($"Select a valid whisper.cpp model file. The path '{sourcePath}' does not exist.", sourcePath);

Type guard

static bool IsValidWhisperCppModelPath(string path) =>
    File.Exists(path) &&
    path.EndsWith(".bin", StringComparison.OrdinalIgnoreCase) &&
    new FileInfo(path).Length >= 10_000_000;

Try / catch

try { var name = engine.ImportCustomModel(sourcePath); }
catch (FileNotFoundException ex)
{ /* re-prompt user with file picker, show ex.FileName for clarity */ }

Prevention

When it happens

Trigger: The user selects a file path in the import dialog that no longer exists (deleted between selection and import); the path is a directory instead of a file; the path is a relative path that resolves differently; the file is on a removable drive that was disconnected.

Common situations: User typed a path manually instead of using the file picker; the file was moved or deleted after selection; network drive disconnected; permission issue preventing File.Exists from seeing the file; the path contains environment variables that weren't expanded.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/ea75c3622f2069e6. Report an issue: GitHub.