HandyOrg/HandyControl · error · ArgumentException
No file exists at
Error message
No file exists at "{0}" What it means
Verify.FileExists validates that a string parameter points to an existing file. It first requires a non-null, non-empty string, then calls File.Exists; when no file exists at the path it throws ArgumentException with the formatted path in the message.
Solutions
- Check File.Exists(path) (with Path.GetFullPath) before calling
- Resolve relative paths against AppContext.BaseDirectory or a known base directory
- Verify the file is deployed/present at the expected absolute path
Example fix
// before
api.Load("config.xml"); // relative to CWD — often wrong
// after
string path = Path.Combine(AppContext.BaseDirectory, "config.xml");
if (!File.Exists(path)) throw new FileNotFoundException("Missing config", path);
api.Load(path); Defensive patterns
Strategy: validation
Validate before calling
string fullPath = Path.GetFullPath(path);
if (string.IsNullOrWhiteSpace(fullPath)) throw new ArgumentException("Path required", nameof(path));
if (!File.Exists(fullPath)) throw new FileNotFoundException("File missing", fullPath); Try / catch
try { api.Load(path); } catch (ArgumentException ex) when (ex.Message.StartsWith("No file exists at")) { /* restore/ship the missing file or prompt user */ } Prevention
- Resolve relative paths against AppContext.BaseDirectory, not CWD
- Check File.Exists before calling and log the absolute path
- Ensure required files are included in deployment/publish output
When it happens
Trigger: Passing a path to an API backed by Verify.FileExists where the file does not exist — wrong relative path (relative to process working directory, not the app), deleted file, wrong drive/extension, or an empty string.
Common situations: Working-directory mismatches between dev and production environments, missing deployment files, typos in file names, passing a directory path instead of a file path.
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
- The streams can't be read for comparison
- The parameter can not be either null or empty.
- The parameter can not be either null or empty or consist…
- The parameter must not be the default value.
- The parameter must be null.
AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14).
Data as JSON: /api/errors/43a4db20ea292a06.
Report an issue: GitHub.
Appendix: source
Thrown at src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs:217
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void TypeSupportsInterface(Type type, Type interfaceType, string parameterName)
{
Verify.IsNotNull<Type>(type, "type");
Verify.IsNotNull<Type>(interfaceType, "interfaceType");
if (type.GetInterface(interfaceType.Name) == null)
{
throw new ArgumentException("The type of this parameter does not support a required interface", parameterName);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DebuggerStepThrough]
public static void FileExists(string filePath, string parameterName)
{
Verify.IsNeitherNullNorEmpty(filePath, parameterName);
if (!File.Exists(filePath))
{
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "No file exists at \"{0}\"", new object[]
{
filePath
}), parameterName);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DebuggerStepThrough]
internal static void ImplementsInterface(object parameter, Type interfaceType, string parameterName)
{
bool flag = false;
foreach (Type left in parameter.GetType().GetInterfaces())
{
if (left == interfaceType)
{
flag = true;
break;
}View on GitHub (pinned to 2c0875ebd6)