{"record":{"id":"9c5fc11d8e99533c","repo":"SubtitleEdit/subtitleedit","slug":"file-not-found","errorCode":null,"errorMessage":"File not found","messagePattern":"File not found","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"warning","filePath":"src/ui/Logic/Media/FileHelper.cs","lineNumber":728,"sourceCode":"                new FilePickerFileType(Se.Language.General.AllFiles)\n                {\n                    Patterns = new List<string> { \"*\" },\n                }\n            };\n\n            return fileTypes;\n        }\n\n        public static void OpenFileWithDefaultProgram(string filePath)\n        {\n            if (string.IsNullOrWhiteSpace(filePath))\n            {\n                throw new ArgumentException(\"File path cannot be null or empty\", nameof(filePath));\n            }\n\n            if (!File.Exists(filePath))\n            {\n                throw new FileNotFoundException(\"File not found\", filePath);\n            }\n\n            try\n            {\n                if (OperatingSystem.IsWindows())\n                {\n                    // Windows: use explorer with the file path\n                    Process.Start(new ProcessStartInfo\n                    {\n                        FileName = filePath,\n                        UseShellExecute = true\n                    });\n                }\n                else if (OperatingSystem.IsMacOS())\n                {\n                    // macOS: use 'open' command\n                    Process.Start(new ProcessStartInfo\n                    {","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Logic/Media/FileHelper.cs#L710-L746","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nFileHelper.OpenFileWithDefaultProgram(path);\n\n// after\nif (!File.Exists(path))\n{\n    showUser($\"File not found: {path}\");\n    return;\n}\nFileHelper.OpenFileWithDefaultProgram(path);","handlingStrategy":"validation","validationCode":"if (!File.Exists(filePath)) { showUser($\"File not found: {filePath}\"); return; }","typeGuard":"static bool FileReadyToOpen(string path) => !string.IsNullOrWhiteSpace(path) && File.Exists(path);","tryCatchPattern":"try { FileHelper.OpenFileWithDefaultProgram(path); }\ncatch (FileNotFoundException ex) { showUser($\"File not found: {ex.FileName}\"); }","preventionTips":["Validate the path exists immediately before offering 'Open'.","Use absolute paths to avoid working-directory resolution surprises."],"tags":["filesystem","file-not-found","validation","precondition"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}