peass-ng/PEASS-ng · error · ArgumentNullException

Value cannot be null. Parameter name: destinationPath

Error message

Value cannot be null.
Parameter name: destinationPath

What it means

File.Move / CopyMove allows destinationPath to be null only when MoveOptions.DelayUntilReboot is specified (pending-rename style move). In every other case a null destinationPath raises ArgumentNullException("destinationPath") during argument validation.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.ValidateFileOrDirectoryMoveArguments.cs:62

         if (cma.PathsChecked)
            return cma;


         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)
            {

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Supply a non-null destination path string.
  2. If a deferred move is intended, add MoveOptions.DelayUntilReboot to the MoveOptions and keep the null destination.
  3. Validate the destination value before calling.

Example fix

// before
File.Move(src, dstPath); // ArgumentNullException when dstPath is null
// after
File.Move(src, dstPath ?? throw new ArgumentException("Destination required."), MoveOptions.DelayUntilReboot);
Defensive patterns

Strategy: validation

Validate before calling

if (destinationPath == null && !moveOptions.HasFlag(MoveOptions.DelayUntilReboot))
    throw new ArgumentException("destinationPath is required unless MoveOptions.DelayUntilReboot is set.", nameof(destinationPath));

Type guard

static bool RequiresDestination(MoveOptions opts) => !opts.HasFlag(MoveOptions.DelayUntilReboot);

Try / catch

try { File.Move(src, destinationPath); }
catch (ArgumentNullException ex) when (ex.ParamName == "destinationPath")
{
    // destination missing and no DelayUntilReboot: compute a default and retry
    File.Move(src, Path.ChangeExtension(src, ".moved"));
}

Prevention

When it happens

Trigger: Calling File.Move(src, null) or File.CopyMove(src, null, ...) without MoveOptions.DelayUntilReboot in the MoveOptions.

Common situations: Code paths where the destination is computed dynamically (e.g. renaming based on a value that came back null); forgetting to pass MoveOptions.DelayUntilReboot when deliberately deferring the move until reboot.

Related errors


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/d8b0a5cd85d965e9. Report an issue: GitHub.