peass-ng/PEASS-ng · error · NotSupportedException

Cannot determine Copy or Move action.

Error message

Cannot determine Copy or Move action.

What it means

File.CopyMoveLogic.IsCopyAction determines whether a copy/move operation is a copy or a move from the presence of CopyOptions vs MoveOptions. If both or neither are set, isCopy equals isMove and the operation cannot be classified, so a NotSupportedException is thrown.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.CopyMoveLogic.cs:75

      /// <summary>Checks if the <see cref="MoveOptions.ReplaceExisting"/> flag is specified.</summary>
      internal static bool HasReplaceExisting(MoveOptions? moveOptions)
      {
         return Utils.IsNotNull(moveOptions) && (moveOptions & MoveOptions.ReplaceExisting) != 0;
      }


      /// <summary>Determine the Copy or Move action.</summary>
      /// <exception cref="NotSupportedException"/>
      internal static bool IsCopyAction(CopyMoveArguments cma)
      {
         // Determine Copy or Move action.

         var isMove = Utils.IsNotNull(cma.MoveOptions) && Equals(null, cma.CopyOptions);

         var isCopy = !isMove && Utils.IsNotNull(cma.CopyOptions);

         if (isCopy.Equals(isMove))
            throw new NotSupportedException(Resources.Cannot_Determine_Copy_Or_Move);

         return isCopy;
      }
   }
}

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Pass exactly one options object: a CopyOptions instance for copy or a MoveOptions instance for move.
  2. If your wrapper holds both, choose one explicitly based on intent and pass null for the other.
  3. If neither is needed, construct a default instance: new CopyOptions() or new MoveOptions().

Example fix

// before
File.CopyMove(src, dst, copyOptions, moveOptions); // NotSupportedException
// after
File.CopyMove(src, dst, copyOptions, null); // or (src, dst, null, moveOptions)
Defensive patterns

Strategy: validation

Validate before calling

static void ValidateCopyMoveArgs(CopyOptions copyOptions, MoveOptions moveOptions)
{
    bool hasCopy = copyOptions != null;
    bool hasMove = moveOptions != null;
    if (hasCopy == hasMove)
        throw new ArgumentException("Pass exactly one of CopyOptions or MoveOptions, not both or neither.");
}

Try / catch

try { File.CopyMove(src, dst, copyOptions, moveOptions); }
catch (NotSupportedException ex) when (ex.Message.Contains("Copy or Move"))
{
    // decide intent explicitly and retry with a single options object
    File.CopyMove(src, dst, new CopyOptions(), null);
}

Prevention

When it happens

Trigger: Calling File.CopyMove (or the directory variant) with both CopyOptions and MoveOptions non-null, or with both null (e.g. copying the same options object into both parameters, or passing neither).

Common situations: Refactoring code that swapped from Copy to Move but left both options set; helper wrappers that forward caller options to both slots; passing null for both because the intent was 'default'.

Related errors


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