{"record":{"id":"2063727f5b51fdcb","repo":"peass-ng/PEASS-ng","slug":"value-cannot-be-null-parameter-name-sourcepath","errorCode":null,"errorMessage":"Value cannot be null.\r\nParameter name: sourcePath","messagePattern":"Value cannot be null\\.\r\nParameter name: sourcePath","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.ValidateFileOrDirectoryMoveArguments.cs","lineNumber":57,"sourceCode":"      private static CopyMoveArguments ValidateFileOrDirectoryMoveArguments(CopyMoveArguments cma, bool driveChecked, bool isFolder, string sourcePath, string destinationPath, out string sourcePathLp, out string destinationPathLp)\n      {\n         sourcePathLp = sourcePath;\n         destinationPathLp = destinationPath;\n         \n         if (cma.PathsChecked)\n            return cma;\n\n\n         cma.IsCopy = IsCopyAction(cma);\n\n         if (!cma.IsCopy)\n            cma.DelayUntilReboot = VerifyDelayUntilReboot(sourcePath, cma.MoveOptions, cma.PathFormat);\n\n\n         if (cma.PathFormat != PathFormat.LongFullPath)\n         {\n            if (null == sourcePath)\n               throw new ArgumentNullException(\"sourcePath\");\n            \n            // File Move action: destinationPath is allowed to be null when MoveOptions.DelayUntilReboot is specified.\n\n            if (!cma.DelayUntilReboot && null == destinationPath)\n               throw new ArgumentNullException(\"destinationPath\");\n            \n\n            if (sourcePath.Trim().Length == 0)\n               throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, \"sourcePath\");\n\n            if (null != destinationPath && destinationPath.Trim().Length == 0)\n               throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, \"destinationPath\");\n\n\n            // MSDN: .NET3.5+: IOException: The sourceDirName and destDirName parameters refer to the same file or directory.\n            // Do not use StringComparison.OrdinalIgnoreCase to allow renaming a folder with different casing.\n\n            if (sourcePath.Equals(destinationPath, StringComparison.Ordinal))","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.ValidateFileOrDirectoryMoveArguments.cs#L39-L75","documentation":"File.Move / CopyMove argument validation requires a non-null sourcePath. When the PathFormat is not LongFullPath (so the path must be validated/normalized), a null sourcePath causes ArgumentNullException(\"sourcePath\").","triggerScenarios":"Calling File.Move(null, dst) or File.CopyMove(null, dst, ...) with a non-LongFullPath PathFormat. Note destinationPath may be null only when MoveOptions.DelayUntilReboot is set; sourcePath may never be null.","commonSituations":"Building paths from variables that failed to resolve (config value, registry value, or command-line argument left null); passing the result of a lookup that returned null.","solutions":["Pass a valid, non-null source path string.","Check the source value for null before calling and fail early with a meaningful message.","Guard config/CLI-derived values with string.IsNullOrEmpty before invoking the move."],"exampleFix":"// before\nFile.Move(srcPath, dstPath); // ArgumentNullException if srcPath is null\n// after\nif (string.IsNullOrEmpty(srcPath))\n    throw new ArgumentException(\"Source path is required.\", nameof(srcPath));\nFile.Move(srcPath, dstPath);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(sourcePath))\n    throw new ArgumentException(\"sourcePath must be a non-empty path.\", nameof(sourcePath));\n// then call File.Move(sourcePath, destinationPath);","typeGuard":"static bool IsValidSourcePath(string p) => !string.IsNullOrWhiteSpace(p);","tryCatchPattern":"try { File.Move(sourcePath, destinationPath); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"sourcePath\")\n{\n    // source never resolved; report/log the configuration problem\n    throw new InvalidOperationException(\"Source path was not provided.\", ex);\n}","preventionTips":["Validate all path inputs with string.IsNullOrWhiteSpace before filesystem calls","Fail fast when config/env/CLI values that supply paths are null","Never pass null for sourcePath even when using DelayUntilReboot (only destination may be null)"],"tags":["arguments","null","argumentnullexception"],"backgroundTag":"null-path-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}