{"record":{"id":"60f79278e658dfed","repo":"peass-ng/PEASS-ng","slug":"value-cannot-be-null-parameter-name-path-60f792","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.EnableDisableEncryptionCore.cs","lineNumber":49,"sourceCode":"      /// <summary>Enables/disables encryption of the specified directory and the files in it.\n      ///   <para>This method only creates/modifies the file \"Desktop.ini\" in the root of <paramref name=\"path\"/> and  enables/disables encryption by writing: \"Disable=0\" or \"Disable=1\".</para>\n      ///   <para>This method does not affect encryption of files and subdirectories below the indicated directory.</para>\n      /// </summary>\n      /// <exception cref=\"ArgumentException\"/>\n      /// <exception cref=\"ArgumentNullException\"/>\n      /// <exception cref=\"DirectoryReadOnlyException\"/>\n      /// <exception cref=\"FileReadOnlyException\"/>\n      /// <exception cref=\"IOException\"/>\n      /// <exception cref=\"NotSupportedException\"/>\n      /// <exception cref=\"UnauthorizedAccessException\"/>\n      /// <param name=\"path\">The name of the directory for which to enable encryption.</param>\n      /// <param name=\"enable\"><c>true</c> enabled encryption, <c>false</c> disables encryption.</param>\n      /// <param name=\"pathFormat\">Indicates the format of the path parameter(s).</param>\n      [SecurityCritical]\n      internal static void EnableDisableEncryptionCore(string path, bool enable, PathFormat pathFormat)\n      {\n         if (Utils.IsNullOrWhiteSpace(path))\n            throw new ArgumentNullException(\"path\");\n\n         var pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck);\n\n         // EncryptionDisable()\n         // 2013-01-13: MSDN does not confirm LongPath usage and no Unicode version of this function exists.\n\n         var success = NativeMethods.EncryptionDisable(pathLp, !enable);\n\n         var lastError = Marshal.GetLastWin32Error();\n         if (!success)\n            NativeError.ThrowException(lastError, true, pathLp);\n      }\n   }\n}\n","sourceCodeStart":31,"sourceCodeEnd":64,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.EnableDisableEncryptionCore.cs#L31-L64","documentation":"EnableDisableEncryptionCore throws ArgumentNullException(\"path\") when the path parameter is null, empty, or whitespace (Utils.IsNullOrWhiteSpace check). Directory.EnableEncryption / DisableEncryption need a concrete directory path to pass to EncryptionDisable, so an empty value is rejected immediately as a caller error.","triggerScenarios":"Calling Directory.EnableEncryption(path, true) or DisableEncryption(path, false) with null/string.Empty/whitespace path; upstream config or registry value missing; a Path.Combine result that came back null/empty because an argument was empty.","commonSituations":"EFS-related setup scripts where the folder setting was never configured; environment-specific config files missing a key; loop variables that are empty on the last iteration of a batch operation.","solutions":["Validate with string.IsNullOrWhiteSpace before calling and raise a meaningful domain error.","Supply a default/known directory when the configured value is missing.","Fix the source of the empty path (config load, env var, argument parsing).","Guard batch loops: skip entries whose resolved path is empty instead of passing them through."],"exampleFix":"// before\nDirectory.EnableEncryption(folderPath, true); // folderPath may be \"\"\n// after\nif (string.IsNullOrWhiteSpace(folderPath))\n    throw new ArgumentException(\"Encrypted folder path is not configured\");\nDirectory.EnableEncryption(folderPath, true);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(path))\n    throw new ArgumentException(\"Directory path is required for EFS operations\", nameof(path));","typeGuard":"bool HasPath(string p) => !string.IsNullOrWhiteSpace(p);","tryCatchPattern":"try { Directory.EnableEncryption(path, enable); }\ncatch (ArgumentNullException ex) { logger.LogError(ex, \"Encryption target path missing\"); }","preventionTips":["Validate config-sourced directory paths before EFS calls","Fail fast on missing settings instead of propagating empty strings","Skip empty entries in batch encryption loops","Use guard clauses in wrappers around AlphaFS encryption APIs"],"tags":["c-sharp","argument-null","efs","encryption","validation"],"backgroundTag":"null-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}