SubtitleEdit/subtitleedit · error · FileNotFoundException
Subtitle file not found: {filePath}
Error message
Subtitle file not found: {filePath} What it means
Thrown by LoadSubtitleWithFormat when the subtitle file does not exist on disk (File.Exists returns false). This is the standard FileNotFoundException — the path is unresolvable, the file was deleted, or the path is wrong. The file path is embedded in the message for diagnostics.
Source
Thrown at src/seconv/Core/LibSEIntegration.cs:65
return entries;
}
public sealed record FormatEntry(SubtitleFormat Format, string Kind);
/// <summary>
/// Loads a subtitle file using LibSE. When <paramref name="encodingName"/> is null/blank,
/// the encoding is auto-detected from the file's content. When
/// <paramref name="fallbackEncodingName"/> is supplied (and <paramref name="encodingName"/>
/// is not), the fallback replaces the ANSI codepage heuristic: a BOM still wins, valid
/// UTF-8 still wins, but anything else uses the fallback rather than DetectAnsiEncoding.
/// Also returns the detected source format so the save side can apply
/// <c>RemoveNativeFormatting</c> if the target is different.
/// </summary>
public static (Subtitle Subtitle, SubtitleFormat Format) LoadSubtitleWithFormat(string filePath, string? encodingName = null, string? fallbackEncodingName = null, List<string>? warnings = null)
{
if (!File.Exists(filePath))
{
throw new FileNotFoundException($"Subtitle file not found: {filePath}");
}
var subtitle = new Subtitle();
Encoding encoding;
if (!string.IsNullOrWhiteSpace(encodingName))
{
encoding = GetEncoding(encodingName);
}
else if (!string.IsNullOrWhiteSpace(fallbackEncodingName))
{
encoding = DetectEncodingWithFallback(filePath, fallbackEncodingName);
}
else
{
encoding = LanguageAutoDetect.GetEncodingFromFile(filePath);
}
var lines = new List<string>(File.ReadAllLines(filePath, encoding));View on GitHub (pinned to 17a9f07487)
Solutions
- Verify the path with File.Exists before calling LoadSubtitleWithFormat, and surface a clean error.
- If the path is relative, resolve it against the intended base directory with Path.GetFullPath before the call.
- Check for typos, trailing spaces, or shell-quoting issues in the argument.
Example fix
// before
var (sub, fmt) = LibSEIntegration.LoadSubtitleWithFormat(path);
// after
if (!File.Exists(path))
throw new FileNotFoundException($"Input subtitle not found: {path}");
var (sub, fmt) = LibSEIntegration.LoadSubtitleWithFormat(path); Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(filePath))
throw new FileNotFoundException($"Subtitle file not found: {filePath}", filePath);
var (sub, fmt) = LibSEIntegration.LoadSubtitleWithFormat(filePath); Type guard
static bool IsSubtitleFileReadable(string path) => File.Exists(path);
Try / catch
try { var (sub, fmt) = LibSEIntegration.LoadSubtitleWithFormat(path); }
catch (FileNotFoundException ex) when (ex.Message.Contains("Subtitle file not found"))
{ /* report missing input file to user, check path/spelling */ } Prevention
- Validate File.Exists for every input path before calling load methods.
- Resolve relative paths to absolute with Path.GetFullPath to surface CWD issues early.
- In CLI tools, validate all input paths in an argument-parsing phase before any processing begins.
When it happens
Trigger: Calling LoadSubtitleWithFormat(filePath, ...) where filePath points to a non-existent file. Common in CLI invocations with a typo'd path, a relative path resolved from the wrong working directory, or a file that was moved/deleted between validation and load.
Common situations: Typo in the CLI input path; relative path resolved against an unexpected CWD (especially in scripts or batch jobs); file on a network mount that dropped; race between file creation and this call.
Related errors
- EBU header file not found: {ebuHeaderFile}
- ASSA style file not found: {assaStyleFile}
- Multiple-replace file not found: {path}
- OCR model file not found: {name}
- No Blu-Ray sup subtitles found in: {filePath}
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/3ef7aa53347da32f.
Report an issue: GitHub.