LykosAI/StabilityMatrix · error · FileNotFoundException
File does not exist
Error message
File does not exist
What it means
LoadImageMetadata loads PNG/image metadata for a dropped or opened file path, but first requires the path be non-null and the file exist. If the FilePath is null or the file is gone, it throws FileNotFoundException with the path as FileName so the caller can report a missing file.
Solutions
- Verify the file exists before calling: File.Exists(path) / path.Exists, and show a 'file not found' dialog otherwise.
- Re-pick/re-drag the file — if it was deleted or moved, restore it or browse to its new location.
- For drop scenarios, canonicalize the dropped payload to a real filesystem path and bail out early if it isn't one.
Example fix
// before
vm.LoadImageMetadata(path); // FileNotFoundException if missing
// after
if (path is not { Exists: true })
{
Dialogs.ShowDialog("File not found", $"{path?.FullPath} no longer exists.");
return;
}
vm.LoadImageMetadata(path); Defensive patterns
Strategy: validation
Validate before calling
if (path is not { Exists: true })
{
Dialogs.ShowDialog("File not found", $"'{path?.FullPath}' does not exist.");
return;
} Type guard
bool Loadable(FilePath? p) => p is { Exists: true }; Try / catch
try { vm.LoadImageMetadata(path); }
catch (FileNotFoundException ex) { Dialogs.ShowDialog("File not found", ex.FileName ?? "unknown path"); } Prevention
- Check File.Exists/path.Exists immediately before opening files from drag-drop or recent-files lists.
- Handle dropped items by copying to a stable location before reading metadata.
- Don't persist raw temp paths across sessions; verify on restore.
When it happens
Trigger: Calling LoadImageMetadata(path) (via Drop or AddTabFromFileAsync) with a null path, a path pointing to a deleted/renamed file, a file on unmounted removable media, or a stale path from a previous session.
Common situations: Dragging a file that was deleted before drop completed; opening an image from a temp folder that was cleaned; files on an external drive/network share that disconnected; OS passing a virtual/non-filesystem drop payload.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- File ( ) was not found
- Model file no longer exists
- Could not find file
- Font NotoSansJP not found
- DockControl not found
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/18862a994a3b3dd4.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs:181
if (disposing)
{
((IPersistentViewProvider)this).AttachedPersistentView = null;
}
}
/// <summary>
/// Loads image and metadata from a file path
/// </summary>
/// <remarks>This is safe to call from non-UI threads</remarks>
/// <param name="filePath">File path</param>
public void LoadImageMetadata(FilePath? filePath)
{
Logger.Info("Loading image metadata from '{Path}'", filePath?.FullPath);
if (filePath is not { Exists: true })
{
throw new FileNotFoundException("File does not exist", filePath?.FullPath);
}
var metadata = ImageMetadata.GetAllFileMetadata(filePath);
LoadImageMetadata(filePath.FullPath, metadata);
}
/// <summary>
/// Loads image and metadata from a LocalImageFile
/// </summary>
/// <param name="localImageFile">LocalImageFile</param>
public void LoadImageMetadata(LocalImageFile localImageFile)
{
Logger.Info("Loading image metadata from LocalImageFile at '{Path}'", localImageFile.AbsolutePath);
var metadata = localImageFile.ReadMetadata();
LoadImageMetadata(localImageFile.AbsolutePath, metadata);View on GitHub (pinned to af93d6ef57)