peass-ng/PEASS-ng · error · ArgumentException
Path is a zero-length string or contains only white space.
Error message
Path is a zero-length string or contains only white space.
What it means
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").
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.ValidateFileOrDirectoryMoveArguments.cs:66
cma.IsCopy = IsCopyAction(cma);
if (!cma.IsCopy)
cma.DelayUntilReboot = VerifyDelayUntilReboot(sourcePath, cma.MoveOptions, cma.PathFormat);
if (cma.PathFormat != PathFormat.LongFullPath)
{
if (null == sourcePath)
throw new ArgumentNullException("sourcePath");
// File Move action: destinationPath is allowed to be null when MoveOptions.DelayUntilReboot is specified.
if (!cma.DelayUntilReboot && null == destinationPath)
throw new ArgumentNullException("destinationPath");
if (sourcePath.Trim().Length == 0)
throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "sourcePath");
if (null != destinationPath && destinationPath.Trim().Length == 0)
throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "destinationPath");
// MSDN: .NET3.5+: IOException: The sourceDirName and destDirName parameters refer to the same file or directory.
// Do not use StringComparison.OrdinalIgnoreCase to allow renaming a folder with different casing.
if (sourcePath.Equals(destinationPath, StringComparison.Ordinal))
NativeError.ThrowException(Win32Errors.ERROR_SAME_DRIVE, destinationPath);
if (!driveChecked)
{
// Check for local or network drives, such as: "C:" or "\\server\c$" (but not for "\\?\GLOBALROOT\").
if (!sourcePath.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase))
Directory.ExistsDriveOrFolderOrFile(cma.Transaction, sourcePath, isFolder, (int) Win32Errors.NO_ERROR, true, false);
View on GitHub (pinned to 53fb989abc)
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.
Example fix
// before
File.Move(srcPath, dstPath); // ArgumentException if srcPath is " "
// after
if (string.IsNullOrWhiteSpace(srcPath))
throw new ArgumentException("Source path must not be empty.", nameof(srcPath));
File.Move(srcPath, dstPath); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(sourcePath))
throw new ArgumentException("sourcePath must not be empty or whitespace.", nameof(sourcePath)); Type guard
static bool IsNonEmptyPath(string p) => !string.IsNullOrWhiteSpace(p);
Try / catch
try { File.Move(sourcePath, destinationPath); }
catch (ArgumentException ex) when (ex.ParamName == "sourcePath")
{
// blank source: skip or surface a configuration error
return;
} Prevention
- 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
When it happens
Trigger: Calling File.Move("", dst), File.Move(" ", dst), or CopyMove with a source that trims to empty (and PathFormat not LongFullPath).
Common situations: Empty environment variables or config keys feeding the path; string splitting producing empty segments; database/registry fields containing whitespace.
Related errors
- Invalid Subpath
- MoveOptions.CopyAllowed is not allowed when using the MoveOp
- PEASS local file (#{url_peass}) does not exist!
- Resources.Cannot_Create_Directory
- Network path is not allowed for directory junction: [{0}]
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/0e669566797ed6cb.
Report an issue: GitHub.