PowerShell Length Calculation Incorrect Using WinSCP assembly
I ran into an interesting problem that I'm not sure if it's a bug or if I'm just doing something incorrect.
I have a need to pull a file via sFTP and have decided to script it using powershell with the WinSCP dll so I can have the best of both.
I start off by enumerating through the remote files.
Then I foreach through the files:
Unfortunately, the value I end up with for the length of the source file is double what the length actually is. I'm getting a value of 52KB while the file is actually 25KB and change.
My goal is to compare a file before and after transfer to validate that the file transferred properly. Can anyone shed light on what I'm doing wrong with the length or suggest a better way to compare pre and post transfer files?
Super appreciated
I have a need to pull a file via sFTP and have decided to script it using powershell with the WinSCP dll so I can have the best of both.
I start off by enumerating through the remote files.
# Begin transfer and logging of file. $FileNames = $session.EnumerateRemoteFiles($FTPPath,"",[WinSCP.EnumerationOptions]::None) $Files = $FileNames.FullName
Then I foreach through the files:
ForEach ($File in $Files) { # Transfer File and log both size and transfer time. $FileLength = $File.Length $FileLength }
Unfortunately, the value I end up with for the length of the source file is double what the length actually is. I'm getting a value of 52KB while the file is actually 25KB and change.
My goal is to compare a file before and after transfer to validate that the file transferred properly. Can anyone shed light on what I'm doing wrong with the length or suggest a better way to compare pre and post transfer files?
Super appreciated