{"record":{"id":"a81e47f28080ae69","repo":"peass-ng/PEASS-ng","slug":"cannot-determine-copy-or-move-action","errorCode":null,"errorMessage":"Cannot determine Copy or Move action.","messagePattern":"Cannot determine Copy or Move action\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.CopyMoveLogic.cs","lineNumber":75,"sourceCode":"      /// <summary>Checks if the <see cref=\"MoveOptions.ReplaceExisting\"/> flag is specified.</summary>\n      internal static bool HasReplaceExisting(MoveOptions? moveOptions)\n      {\n         return Utils.IsNotNull(moveOptions) && (moveOptions & MoveOptions.ReplaceExisting) != 0;\n      }\n\n\n      /// <summary>Determine the Copy or Move action.</summary>\n      /// <exception cref=\"NotSupportedException\"/>\n      internal static bool IsCopyAction(CopyMoveArguments cma)\n      {\n         // Determine Copy or Move action.\n\n         var isMove = Utils.IsNotNull(cma.MoveOptions) && Equals(null, cma.CopyOptions);\n\n         var isCopy = !isMove && Utils.IsNotNull(cma.CopyOptions);\n\n         if (isCopy.Equals(isMove))\n            throw new NotSupportedException(Resources.Cannot_Determine_Copy_Or_Move);\n\n         return isCopy;\n      }\n   }\n}\n","sourceCodeStart":57,"sourceCodeEnd":81,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/File Class/File CopyMove/File.CopyMoveLogic.cs#L57-L81","documentation":"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.","triggerScenarios":"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).","commonSituations":"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'.","solutions":["Pass exactly one options object: a CopyOptions instance for copy or a MoveOptions instance for move.","If your wrapper holds both, choose one explicitly based on intent and pass null for the other.","If neither is needed, construct a default instance: new CopyOptions() or new MoveOptions()."],"exampleFix":"// before\nFile.CopyMove(src, dst, copyOptions, moveOptions); // NotSupportedException\n// after\nFile.CopyMove(src, dst, copyOptions, null); // or (src, dst, null, moveOptions)","handlingStrategy":"validation","validationCode":"static void ValidateCopyMoveArgs(CopyOptions copyOptions, MoveOptions moveOptions)\n{\n    bool hasCopy = copyOptions != null;\n    bool hasMove = moveOptions != null;\n    if (hasCopy == hasMove)\n        throw new ArgumentException(\"Pass exactly one of CopyOptions or MoveOptions, not both or neither.\");\n}","typeGuard":null,"tryCatchPattern":"try { File.CopyMove(src, dst, copyOptions, moveOptions); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"Copy or Move\"))\n{\n    // decide intent explicitly and retry with a single options object\n    File.CopyMove(src, dst, new CopyOptions(), null);\n}","preventionTips":["Pass exactly one of CopyOptions / MoveOptions, never both","Use new CopyOptions() rather than null when no special options are needed","Wrap CopyMove in a helper that enforces the single-options invariant","Review refactors that swap Copy<->Move for leftover options"],"tags":["arguments","copy-move","notsupportedexception"],"backgroundTag":"ambiguous-copy-move-options","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}