{"record":{"id":"3c863a1e3023d532","repo":"dotnet/maui","slug":"no-file-exists-at-0","errorCode":null,"errorMessage":"No file exists at \"{0}\"","messagePattern":"No file exists at \"(.+?)\"","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/WPF/Microsoft.Windows.Shell/Standard/Verify.cs","lineNumber":297,"sourceCode":"\t\t\tVerify.IsNotNull(type, \"type\");\n\t\t\tVerify.IsNotNull(interfaceType, \"interfaceType\");\n\n\t\t\tif (type.GetInterface(interfaceType.Name) == null)\n\t\t\t{\n\t\t\t\tAssert.Fail();\n\t\t\t\tthrow new ArgumentException(\"The type of this parameter does not support a required interface\", parameterName);\n\t\t\t}\n\t\t}\n\n\t\t[SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n\t\t[DebuggerStepThrough]\n\t\tpublic static void FileExists(string filePath, string parameterName)\n\t\t{\n\t\t\tVerify.IsNeitherNullNorEmpty(filePath, parameterName);\n\t\t\tif (!File.Exists(filePath))\n\t\t\t{\n\t\t\t\tAssert.Fail();\n\t\t\t\tthrow new ArgumentException(string.Format(CultureInfo.InvariantCulture, \"No file exists at \\\"{0}\\\"\", filePath), parameterName);\n\t\t\t}\n\t\t}\n\n\t\t[SuppressMessage(\"Microsoft.Performance\", \"CA1811:AvoidUncalledPrivateCode\")]\n\t\t[DebuggerStepThrough]\n\t\tinternal static void ImplementsInterface(object parameter, Type interfaceType, string parameterName)\n\t\t{\n\t\t\tAssert.IsNotNull(parameter);\n\t\t\tAssert.IsNotNull(interfaceType);\n\t\t\tAssert.IsTrue(interfaceType.IsInterface);\n\n\t\t\tbool isImplemented = false;\n\t\t\tforeach (var ifaceType in parameter.GetType().GetInterfaces())\n\t\t\t{\n\t\t\t\tif (ifaceType == interfaceType)\n\t\t\t\t{\n\t\t\t\t\tisImplemented = true;\n\t\t\t\t\tbreak;","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/WPF/Microsoft.Windows.Shell/Standard/Verify.cs#L279-L315","documentation":"Verify.FileExists throws ArgumentException when File.Exists(filePath) returns false. It combines IsNeitherNullNorEmpty on the path with a filesystem existence check, so the message formats the offending path. It is a precondition guard for APIs that require a real file on disk.","triggerScenarios":"Calling a method guarded by Verify.FileExists(filePath, paramName) where the file does not exist at the given path. The guard fires before any attempt to open or read the file.","commonSituations":"Relative path resolved against the wrong working directory; missing deployment artifact; user-supplied path with a typo; file deleted between a prior check and the call; path environment differences between dev and production.","solutions":["Verify File.Exists(path) at the call site before invoking the API.","Resolve paths to absolute with Path.GetFullPath and log the resolved path for debugging.","Check the deployment package includes the file and the working directory is correct."],"exampleFix":"// before\nloader.Load(templatePath); // file may not exist\n\n// after\nvar fullPath = Path.GetFullPath(templatePath);\nif (!File.Exists(fullPath))\n{\n    throw new FileNotFoundException($\"Template not found: {fullPath}\", fullPath);\n}\nloader.Load(fullPath);","handlingStrategy":"validation","validationCode":"// Pre-check: file must exist\nvar fullPath = Path.GetFullPath(filePath);\nif (!File.Exists(fullPath))\n{\n    throw new FileNotFoundException($\"File not found: {fullPath}\", fullPath);\n}\nSomeApi(fullPath);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve paths to absolute with Path.GetFullPath and log them for debugging.","Verify the working directory is correct before file operations.","Ensure deployment packages include all required files."],"tags":["validation","io","file-exists","argument","verify"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}