GetFileToDirectory Not Overwriting File, even though OverWriteMode set to Overwrite

Advertisement

ralphsmorra
Joined:
Posts:
1

GetFileToDirectory Not Overwriting File, even though OverWriteMode set to Overwrite

I'm downloading one file at a time using $session.GetFileToDirectory in PowerShell, yet if a file of the same name already exists in the local folder, it is not getting overwritten, *which I want it to*, in this case.

I could delete the local file manually if present, before downloading, but WinSCP has an OverwriteMode, yet I may have its syntax wrong, because it's not overwriting, even though I am setting it to.

Please check these $transferOptions and let me know what if anything I can do to cause files with the same name downloaded via GetFileToDirectory to overwrite identically named files in the local directory.
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.PreserveTimestamp = $true
$transferOptions.FilePermissions = $Null # This is default
$transferOptions.transferOptions = [WinSCP.OverwriteMode]::Overwrite

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum