Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The FTP methods don't support downloading of folders, or recursion, by themselves, so there's no other way I can think of doing this but what I've suggested below.</p> <p>Change the method so you can differentiate between files and directories and handle them accordingly.</p> <p>Change <code>$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectory</code> to <code>$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectoryDetails</code></p> <p>Which will list in this format:</p> <pre><code>-rwxrwxrwx 1 owner group 277632 Mar 4 17:15 xml_socket.log.rar </code></pre> <p>Directories will have a <code>d</code> in place of the <code>-</code> at the start of the line.</p> <p>Here is an amended <code>try</code> block that will match only files so you can pass to the <code>downloadFtp</code> function:</p> <pre><code> try { if(!($filename -match '^d')){if((Test-Path ("C:\emsdropbox\"+$filename.Split(" ")[8])) -ne $true) { downloadFtp(($filename -split '\s+')[8]) }} $filename = $FTPReader.ReadLine() } </code></pre> <p>If you want to then get a list of directories, use the following <code>try</code> block against the same ftpresponse stream and for each, <code>ListDirectoryDetails</code> to get the list of files in each directory to process them:</p> <pre><code> try { if($filename -match '^d'){if((Test-Path ("C:\emsdropbox\"+$filename.Split(" ")[8])) -ne $true) { listdir(($filename -split '\s+')[8]) }} $filename = $FTPReader.ReadLine() } </code></pre> <p>You may also have to create the local directories too which you can do in powershell as follows:</p> <pre><code>New-Item c:\emsdropbox\newdir -type directory </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload