Topic "Winscp 5.1.5 .Net library removes files after downloading"

Author Message
dimic
[View user's profile]

Joined: 2013-07-10
Posts: 4
Hi!
I use Powershell with WinSP library ( 5.1.5).
I discovered one strange thing - method GetFiles for some reasonm removes source files
I've tried to use 2 variants of the command:
$session.GetFiles(($remotePath + $i.Name ), $localPath,"false",$transferOptions).Check()
$session.GetFiles(($remotePath + $i.Name ), $localPath,$transferOptions).Check()
These commands downloads all files from a _folder_ on a FTP server.

Files were downloaded and after that the source folder become removed.
Advertisements
dimic
[View user's profile]

Joined: 2013-07-10
Posts: 4
Seems that this happens not only for folders, but also for files
In the debug log I always see something like:
<group name="get -delete -nopermissions -preservetime -transfer=&quot;binary&quot; -- &quot;/PA/dimic/temp2/1031/BM_1031_1300_tr.mp4&quot; &quot;d:\temp\mp4\*&quot;" start="2013-07-10T15:08:43.665Z">
<download>
<filename value="/PA/dimic/temp2/1031/BM_1031_1300_tr.mp4" />
<destination value="d:\temp\mp4\BM_1031_1300_tr.mp4" />
<result success="true" />
</download>
<rm>
<filename value="/PA/dimic/temp2/1031/BM_1031_1300_tr.mp4" />
<result success="true" />
</rm>
</group>
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
I do not know PowerShell enough to tell, what it exactly does when you pass a "false" to boolean parameter. But obviously it interprets it a as a true. You should use $False instead.

For example see http://winscp.net/eng/docs/library_powershell#example
_________________
Martin Prikryl
dimic
[View user's profile]

Joined: 2013-07-10
Posts: 4
Aha! Thanks Martin!
I'm new in Powershell, stupid mistake.

But I still have a question regarding skipped boolean parameter. As far as I understood from documentation, the default value for skipped parameter should be False, but the command
$session.GetFiles(($remotePath + $i.Name ), $localPath,$transferOptions).Check()
anyway removes source files from FTP
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
dimic wrote:
But I still have a question regarding skipped boolean parameter. As far as I understood from documentation, the default value for skipped parameter should be False, but the command
$session.GetFiles(($remotePath + $i.Name ), $localPath,$transferOptions).Check()
anyway removes source files from FTP

Now you are passing $transferOptions to remove parameter. As it is non-empty object, I expect again that PowerShell interprets it as True.
dimic
[View user's profile]

Joined: 2013-07-10
Posts: 4
I see, thanks!
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License