dotnet/wpf · error · ArgumentException
No file exists at
Error message
No file exists at "{filePath}" What it means
Verify.FileExists throws ArgumentException when the supplied path is non-empty but File.Exists(filePath) returns false, i.e. no file is present at that path at call time. The message includes the offending path and the exception names the parameter.
Solutions
- Check File.Exists(path) before calling and correct the path.
- Use an absolute path built via Path.Combine(AppContext.BaseDirectory, ...) instead of relying on the current working directory.
- Verify the file was deployed/copied with the application and confirm spelling and extension.
Example fix
// before
theme.Load("res\\Theme.xaml");
// after
string path = Path.Combine(AppContext.BaseDirectory, "res", "Theme.xaml");
if (!File.Exists(path)) throw new FileNotFoundException(path);
theme.Load(path); Defensive patterns
Strategy: validation
Validate before calling
string fullPath = Path.GetFullPath(path);
if (!File.Exists(fullPath)) throw new FileNotFoundException($"Missing file: {fullPath}", fullPath); Try / catch
try { api.Load(path); }
catch (ArgumentException ex) when (ex.Message.StartsWith("No file exists at")) { /* prompt user or fall back to default resource */ } Prevention
- Always resolve relative paths against AppContext.BaseDirectory, not the working directory.
- Check File.Exists immediately before the call; don't cache existence results across long operations.
- Include expected data files in deployment/publish outputs.
When it happens
Trigger: Calling a WPF API that calls Verify.FileExists (e.g. resource/font/image loading helpers) with a path to a nonexistent file, or calling Verify.FileExists directly with a stale path.
Common situations: Typo in file name or extension; file deleted or moved after path was computed; relative path resolved against an unexpected working directory; case-sensitivity issues when deploying from Windows to a case-sensitive volume; running without access to a network share makes the file appear missing.
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
- SR.FileNotFoundExceptionWithFileName
- ArgumentOutOfRangeException(nameof(offset))
- can’t seek on baseStream
- Cannot open data stream.
- Image_CannotCreateTempFile
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/62e25c2c2b3ebd9e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Standard/Verify.cs:267
public static void TypeSupportsInterface(Type type, Type interfaceType, string parameterName)
{
Assert.IsNeitherNullNorEmpty(parameterName);
Verify.IsNotNull(type, "type");
Verify.IsNotNull(interfaceType, "interfaceType");
if (type.GetInterface(interfaceType.Name) == null)
{
throw new ArgumentException("The type of this parameter does not support a required interface", parameterName);
}
}
[DebuggerStepThrough]
public static void FileExists(string filePath, string parameterName)
{
Verify.IsNeitherNullNorEmpty(filePath, parameterName);
if (!File.Exists(filePath))
{
throw new ArgumentException($"No file exists at \"{filePath}\"", parameterName);
}
}
[DebuggerStepThrough]
internal static void ImplementsInterface(object parameter, Type interfaceType, string parameterName)
{
Assert.IsNotNull(parameter);
Assert.IsNotNull(interfaceType);
Assert.IsTrue(interfaceType.IsInterface);
bool isImplemented = false;
foreach (var ifaceType in parameter.GetType().GetInterfaces())
{
if (ifaceType == interfaceType)
{
isImplemented = true;
break;
}View on GitHub (pinned to 81131a70a4)