{"record":{"id":"a60ac1cae2d171f1","repo":"peass-ng/PEASS-ng","slug":"value-cannot-be-null-parameter-name-path","errorCode":null,"errorMessage":"Value cannot be null.\r\nParameter name: path","messagePattern":"Value cannot be null\\.\r\nParameter name: path","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.DeleteDirectoryCore.cs","lineNumber":54,"sourceCode":"      /// <exception cref=\"DirectoryNotFoundException\"/>\n      /// <exception cref=\"IOException\"/>\n      /// <exception cref=\"NotSupportedException\"/>\n      /// <exception cref=\"UnauthorizedAccessException\"/>\n      /// <exception cref=\"DirectoryReadOnlyException\"/>\n      /// <param name=\"transaction\">The transaction.</param>\n      /// <param name=\"fsEntryInfo\">A FileSystemEntryInfo instance. Use either <paramref name=\"fsEntryInfo\"/> or <paramref name=\"path\"/>, not both.</param>\n      /// <param name=\"path\">The name of the directory to remove. Use either <paramref name=\"path\"/> or <paramref name=\"fsEntryInfo\"/>, not both.</param>\n      /// <param name=\"recursive\"><c>true</c> to remove all files and subdirectories recursively; <c>false</c> otherwise only the top level empty directory.</param>\n      /// <param name=\"ignoreReadOnly\"><c>true</c> overrides read only attribute of files and directories.</param>\n      /// <param name=\"continueOnNotFound\">When <c>true</c> does not throw an <see cref=\"DirectoryNotFoundException\"/> when the directory does not exist.</param>\n      /// <param name=\"pathFormat\">Indicates the format of the path parameter(s).</param>\n      [SecurityCritical]\n      internal static void DeleteDirectoryCore(KernelTransaction transaction, FileSystemEntryInfo fsEntryInfo, string path, bool recursive, bool ignoreReadOnly, bool continueOnNotFound, PathFormat pathFormat)\n      {\n         if (null == fsEntryInfo)\n         {\n            if (null == path)\n               throw new ArgumentNullException(\"path\");\n            \n            fsEntryInfo = File.GetFileSystemEntryInfoCore(transaction, true, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator), continueOnNotFound, pathFormat);\n\n            if (null == fsEntryInfo)\n               return;\n         }\n\n\n         PrepareDirectoryForDelete(transaction, fsEntryInfo, ignoreReadOnly);\n\n\n         // Do not follow mount points nor symbolic links, but do delete the reparse point itself.\n         // If directory is reparse point, disable recursion.\n\n         if (recursive && !fsEntryInfo.IsReparsePoint)\n         {\n            // The stack will contain the entire folder structure to prevent any open directory handles because of enumeration.\n            // The root folder is at the bottom of the stack.","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.DeleteDirectoryCore.cs#L36-L72","documentation":"DeleteDirectoryCore throws ArgumentNullException(\"path\") when both the fsEntryInfo parameter and the path parameter are null. The method needs at least one way to identify the directory to delete: if fsEntryInfo is not supplied, it resolves fsEntryInfo from path via GetFileSystemEntryInfoCore, so a null path with null fsEntryInfo is unrecoverable. This is a caller programming error, not an OS error.","triggerScenarios":"Passing null for path (and null fsEntryInfo) to Directory.Delete or any of its wrappers that route through DeleteDirectoryCore (CopyMoveCore, CopyMoveDirectoryCore, CreateJunctionCore, DeleteEmptySubdirectoriesCore, DeleteJunctionCore). Typically the result of an uninitialized or failed path-computation upstream (e.g. Path.Combine returned null via a null argument).","commonSituations":"A configuration value or command-line argument for the directory was missing; a lookup that should produce a path returned null and was passed straight to Delete; deserialization left a path property null.","solutions":["Validate the path with string.IsNullOrWhiteSpace before calling Delete and fail fast with your own error.","Ensure upstream path-building code (Path.Combine, config reads) cannot yield null.","Pass a valid FileSystemEntryInfo obtained from File.GetFileSystemEntryInfo if you prefer object-based deletion.","Catch ArgumentNullException at the boundary to convert it into a user-facing 'directory not specified' message."],"exampleFix":"// before\nDirectory.Delete(configuredPath, true); // configuredPath may be null\n// after\nif (string.IsNullOrWhiteSpace(configuredPath))\n    throw new InvalidOperationException(\"No directory configured for deletion\");\nDirectory.Delete(configuredPath, true);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(path))\n    throw new ArgumentException(\"A directory path is required\", nameof(path));","typeGuard":"bool HasPath(string p) => !string.IsNullOrWhiteSpace(p);","tryCatchPattern":"try { Directory.Delete(path, recursive); }\ncatch (ArgumentNullException ex) { logger.LogError(ex, \"Delete called without a path\"); }","preventionTips":["Validate all path inputs at API boundaries","Never pass possibly-null results of Path.Combine/config reads directly to Delete","Use ArgumentException checks in wrapper methods around AlphaFS","Enable nullable reference types to catch null path flow at compile time"],"tags":["c-sharp","argument-null","filesystem","validation"],"backgroundTag":"null-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}