DevToys-app/DevToys · error · FileNotFoundException

Unable to find the indicated file.

Error message

Unable to find the indicated file.

What it means

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.

Source

Thrown at src/app/dev/platforms/desktop/DevToys.Linux/Core/FileStorage.cs:34

    {
        if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
        {
            relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
        }

        return File.Exists(relativeOrAbsoluteFilePath);
    }

    public FileStream OpenReadFile(string relativeOrAbsoluteFilePath)
    {
        if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
        {
            relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
        }

        if (!File.Exists(relativeOrAbsoluteFilePath))
        {
            throw new FileNotFoundException("Unable to find the indicated file.", relativeOrAbsoluteFilePath);
        }

        return new FileStream(relativeOrAbsoluteFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, SandboxedFileReader.BufferSize, FileOptions.Asynchronous | FileOptions.SequentialScan);
    }

    public FileStream OpenWriteFile(string relativeOrAbsoluteFilePath, bool replaceIfExist)
    {
        if (!Path.IsPathRooted(relativeOrAbsoluteFilePath))
        {
            relativeOrAbsoluteFilePath = Path.Combine(AppCacheDirectory, relativeOrAbsoluteFilePath);
        }

        if (File.Exists(relativeOrAbsoluteFilePath) && replaceIfExist)
        {
            File.Delete(relativeOrAbsoluteFilePath);
        }

        string parentDirectory = Path.GetDirectoryName(relativeOrAbsoluteFilePath)!;

View on GitHub (pinned to 7e12df8448)

Solutions

  1. Call IFileStorage.FileExists(path) immediately before OpenReadFile and handle the false case.
  2. Print/inspect the resolved path (AppCacheDirectory joined with the relative segment) to confirm location.
  3. On case-sensitive Linux filesystems, match the exact filename casing.
  4. Ensure the producer (OpenWriteFile) completed before the consumer reads.
  5. Catch FileNotFoundException and recover (recreate, reprompt, skip).

Example fix

// before
using FileStream stream = fileStorage.OpenReadFile(relativePath);

// after
if (!fileStorage.FileExists(relativePath))
{
    return; // or recreate / reprompt
}
using FileStream stream = fileStorage.OpenReadFile(relativePath);
Defensive patterns

Strategy: validation

Validate before calling

string resolved = Path.IsPathRooted(path) ? path : Path.Combine(fileStorage.AppCacheDirectory, path);
if (!File.Exists(resolved))
{
    return; // or recreate / reprompt
}
using FileStream stream = fileStorage.OpenReadFile(path);

Try / catch

try
{
    using FileStream stream = fileStorage.OpenReadFile(path);
}
catch (FileNotFoundException ex)
{
    // expected missing file — recreate or skip
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of DevToys-app/DevToys@7e12df8448 (2026-08-13). Data as JSON: /api/errors/56a18b8fc14b9d9a. Report an issue: GitHub.