{"record":{"id":"0e669566797ed6cb","repo":"peass-ng/PEASS-ng","slug":"path-is-a-zero-length-string-or-contains-only-whit","errorCode":null,"errorMessage":"Path is a zero-length string or contains only white space.","messagePattern":"Path is a zero-length string or contains only white space\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.ValidateFileOrDirectoryMoveArguments.cs","lineNumber":66,"sourceCode":"         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))\n               NativeError.ThrowException(Win32Errors.ERROR_SAME_DRIVE, destinationPath);\n\n\n            if (!driveChecked)\n            {\n               // Check for local or network drives, such as: \"C:\" or \"\\\\server\\c$\" (but not for \"\\\\?\\GLOBALROOT\\\").\n               if (!sourcePath.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase))\n                  Directory.ExistsDriveOrFolderOrFile(cma.Transaction, sourcePath, isFolder, (int) Win32Errors.NO_ERROR, true, false);\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.ValidateFileOrDirectoryMoveArguments.cs#L48-L84","documentation":"The sourcePath passed to File.Move / CopyMove is validated to not be a zero-length or all-whitespace string. An empty/whitespace source yields ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, \"sourcePath\").","triggerScenarios":"Calling File.Move(\"\", dst), File.Move(\"   \", dst), or CopyMove with a source that trims to empty (and PathFormat not LongFullPath).","commonSituations":"Empty environment variables or config keys feeding the path; string splitting producing empty segments; database/registry fields containing whitespace.","solutions":["Provide a real source path; check string.IsNullOrWhiteSpace(sourcePath) before calling.","Fail early with a domain-specific message when the configured source is blank.","Trim and validate user/config input at the boundary before constructing paths."],"exampleFix":"// before\nFile.Move(srcPath, dstPath); // ArgumentException if srcPath is \" \"\n// after\nif (string.IsNullOrWhiteSpace(srcPath))\n    throw new ArgumentException(\"Source path must not be empty.\", nameof(srcPath));\nFile.Move(srcPath, dstPath);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(sourcePath))\n    throw new ArgumentException(\"sourcePath must not be empty or whitespace.\", nameof(sourcePath));","typeGuard":"static bool IsNonEmptyPath(string p) => !string.IsNullOrWhiteSpace(p);","tryCatchPattern":"try { File.Move(sourcePath, destinationPath); }\ncatch (ArgumentException ex) when (ex.ParamName == \"sourcePath\")\n{\n    // blank source: skip or surface a configuration error\n    return;\n}","preventionTips":["Use string.IsNullOrWhiteSpace checks on every path argument at API boundaries","Trim and verify values read from config, env vars, or string splits","Prefer explicit failure over silently passing empty strings downstream"],"tags":["arguments","path","argumentexception"],"backgroundTag":"empty-path-argument","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}