{"record":{"id":"56a18b8fc14b9d9a","repo":"DevToys-app/DevToys","slug":"unable-to-find-the-indicated-file-56a18b","errorCode":null,"errorMessage":"Unable to find the indicated file.","messagePattern":"Unable to find the indicated file\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/app/dev/platforms/desktop/DevToys.Linux/Core/FileStorage.cs","lineNumber":34,"sourceCode":"    {\n        if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))\n        {\n            relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);\n        }\n\n        return File.Exists(relativeOrAbsoluteFilePath);\n    }\n\n    public FileStream OpenReadFile(string relativeOrAbsoluteFilePath)\n    {\n        if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))\n        {\n            relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);\n        }\n\n        if (!File.Exists(relativeOrAbsoluteFilePath))\n        {\n            throw new FileNotFoundException(\"Unable to find the indicated file.\", relativeOrAbsoluteFilePath);\n        }\n\n        return new FileStream(relativeOrAbsoluteFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, SandboxedFileReader.BufferSize, FileOptions.Asynchronous | FileOptions.SequentialScan);\n    }\n\n    public FileStream OpenWriteFile(string relativeOrAbsoluteFilePath, bool replaceIfExist)\n    {\n        if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))\n        {\n            relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);\n        }\n\n        if (File.Exists(relativeOrAbsoluteFilePath) && replaceIfExist)\n        {\n            File.Delete(relativeOrAbsoluteFilePath);\n        }\n\n        string parentDirectory = Path.GetDirectoryName(relativeOrAbsoluteFilePath)!;","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/DevToys-app/DevToys/blob/7e12df8448aa1f6aec4a8736b3e06a1c90530715/src/app/dev/platforms/desktop/DevToys.Linux/Core/FileStorage.cs#L16-L52","documentation":"Thrown by DevToys.Linux FileStorage.OpenReadFile after resolving a relative path against AppCacheDirectory (Constants.AppCacheDirectory) and finding the file absent via File.Exists. It is the Linux platform's implementation of the same IFileStorage.OpenReadFile contract used by CLI, MacOS, and Windows. FileNotFoundException carries the resolved path as its fileName.","triggerScenarios":"Calling IFileStorage.OpenReadFile with a relative path that does not exist under AppCacheDirectory; an absolute path to a missing file; a file deleted between FileExists and OpenReadFile; a case-sensitivity mismatch (Linux filesystems are case-sensitive).","commonSituations":"Cache/temp file not created by a prior step; app cache dir relocated or cleared; path casing differs from the on-disk name; a file picked through the Gtk file chooser then removed externally.","solutions":["Call IFileStorage.FileExists(path) immediately before OpenReadFile and handle the false case.","Print/inspect the resolved path (AppCacheDirectory joined with the relative segment) to confirm location.","On case-sensitive Linux filesystems, match the exact filename casing.","Ensure the producer (OpenWriteFile) completed before the consumer reads.","Catch FileNotFoundException and recover (recreate, reprompt, skip)."],"exampleFix":"// before\nusing FileStream stream = fileStorage.OpenReadFile(relativePath);\n\n// after\nif (!fileStorage.FileExists(relativePath))\n{\n    return; // or recreate / reprompt\n}\nusing FileStream stream = fileStorage.OpenReadFile(relativePath);","handlingStrategy":"validation","validationCode":"string resolved = Path.IsPathRooted(path) ? path : Path.Combine(fileStorage.AppCacheDirectory, path);\nif (!File.Exists(resolved))\n{\n    return; // or recreate / reprompt\n}\nusing FileStream stream = fileStorage.OpenReadFile(path);","typeGuard":null,"tryCatchPattern":"try\n{\n    using FileStream stream = fileStorage.OpenReadFile(path);\n}\ncatch (FileNotFoundException ex)\n{\n    // expected missing file — recreate or skip\n}","preventionTips":["Always precede OpenReadFile with FileExists on Linux; the filesystem is case-sensitive so verify casing too.","Log the resolved path (AppCacheDirectory + relative) for missing-file diagnostics.","Ensure the producer (OpenWriteFile) finished and closed the file before reading.","Catch FileNotFoundException at the call site and degrade gracefully."],"tags":["csharp","file-io","filestorage","linux","toctou"],"backgroundTag":null,"analyzedSha":"7e12df8448aa1f6aec4a8736b3e06a1c90530715","analyzedAt":"2026-08-13T10:27:33.924Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}