SubtitleEdit/subtitleedit · warning · FileNotFoundException
File not found
Error message
File not found
What it means
Thrown by FileHelper.OpenFileWithDefaultProgram when the supplied filePath does not exist on disk (File.Exists returns false). It is an explicit precondition before any Process.Start attempt, so the path is validated before the OS is asked to open it. FileNotFoundException carries the missing path in its FileName property.
Source
Thrown at src/ui/Logic/Media/FileHelper.cs:728
new FilePickerFileType(Se.Language.General.AllFiles)
{
Patterns = new List<string> { "*" },
}
};
return fileTypes;
}
public static void OpenFileWithDefaultProgram(string filePath)
{
if (string.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentException("File path cannot be null or empty", nameof(filePath));
}
if (!File.Exists(filePath))
{
throw new FileNotFoundException("File not found", filePath);
}
try
{
if (OperatingSystem.IsWindows())
{
// Windows: use explorer with the file path
Process.Start(new ProcessStartInfo
{
FileName = filePath,
UseShellExecute = true
});
}
else if (OperatingSystem.IsMacOS())
{
// macOS: use 'open' command
Process.Start(new ProcessStartInfo
{View on GitHub (pinned to 17a9f07487)
Solutions
- Verify the file exists (File.Exists) before calling, and surface a 'file missing' message to the user instead of letting it throw.
- Use an absolute path; relative paths can resolve against the wrong working directory.
- If the file was generated by an earlier step, ensure that step completed and wrote to the expected location before offering 'Open'.
- Refresh the file list / re-check the path if it may have been moved by the user.
Example fix
// before
FileHelper.OpenFileWithDefaultProgram(path);
// after
if (!File.Exists(path))
{
showUser($"File not found: {path}");
return;
}
FileHelper.OpenFileWithDefaultProgram(path); Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(filePath)) { showUser($"File not found: {filePath}"); return; } Type guard
static bool FileReadyToOpen(string path) => !string.IsNullOrWhiteSpace(path) && File.Exists(path);
Try / catch
try { FileHelper.OpenFileWithDefaultProgram(path); }
catch (FileNotFoundException ex) { showUser($"File not found: {ex.FileName}"); } Prevention
- Validate the path exists immediately before offering 'Open'.
- Use absolute paths to avoid working-directory resolution surprises.
When it happens
Trigger: Calling OpenFileWithDefaultProgram with a path to a file that was deleted, never written, or points to a different machine/relative location that does not resolve.
Common situations: Opening a generated subtitle/export/waveform file that was cleaned up; a relative path that resolved differently than expected; a file on removable media that was ejected.
Related errors
- Subtitle file not found: {filePath}
- EBU header file not found: {ebuHeaderFile}
- ASSA style file not found: {assaStyleFile}
- OCR model file not found: {name}
- Multiple-replace file not found: {path}
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/9c5fc11d8e99533c.
Report an issue: GitHub.