Browse Source

Don't throw error when 'Force' switch is specified

This fixes error when 'Copy-Item2 -Force' would not overwrite existing files
tags/4.2.4
Kris Borowinski 7 years ago
committed by GitHub
parent
commit
168b8b4465
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      NTFSSecurity/ItemCmdlets/CopyItem2.cs

+ 2
- 2
NTFSSecurity/ItemCmdlets/CopyItem2.cs View File

@@ -85,7 +85,7 @@ namespace NTFSSecurity
actualDestination = destination; actualDestination = destination;
} }


if (File.Exists(actualDestination))
if (!force & File.Exists(actualDestination))
{ {
WriteError(new ErrorRecord(new AlreadyExistsException(), "DestinationFileAlreadyExists", ErrorCategory.ResourceExists, actualDestination)); WriteError(new ErrorRecord(new AlreadyExistsException(), "DestinationFileAlreadyExists", ErrorCategory.ResourceExists, actualDestination));
return; return;
@@ -129,4 +129,4 @@ namespace NTFSSecurity
base.EndProcessing(); base.EndProcessing();
} }
} }
}
}

Loading…
Cancel
Save