Topic "How can i get a Filelist like Get-Childitem"

Author Message
shannra666
[View user's profile]

Joined: 2013-04-17
Posts: 1
Hello,

we using Winscp .Net assembly to download Files from Ftp to a local Folder. Now sometimes it interrupt without any error. So my Files are not completed. So i will ad in my Windows Task a New Script. This Script should compare the Ftp-Folder with my local Folder. If not all Files from FTP in my local Folder, then win SCP should start sync again.

But i try the following without success, because the File List Remote cant be compare with the file List which i get with Get-Childitem from local Folder.

Code:

$rz_log = "C:\src\logs\RZ\RZ_log_Log_"+(get-date -format "yy-MM-dd")+".txt"
try
{
    # Load WinSCP .NET assembly
    # Use "winscp.dll" for the releases before the latest beta version.
    [Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\WinSCP\WinSCP.dll") | Out-Null
 
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions
    $sessionOptions.Protocol = [WinSCP.Protocol]::ftp
    $sessionOptions.HostName = "FTP-Server"
    $sessionOptions.UserName = "FTP-User"
    $sessionOptions.Password = "FTP-Pass"
 
    $session = New-Object WinSCP.Session
 

    try
    {
        # Connect
        $session.Open($sessionOptions)
        $directory = $session.ListDirectory("/clara-17")
        Compare-Object -ReferenceObject  $(Get-ChildItem 'FolderLocal' -Recurse) -DifferenceObject  $directory  -Property Name
                foreach ($fileInfo in $directory.Files)
        {
          Write-Host ("{0}" -f
                $fileInfo.Name)
        }
    }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    #exit 0
}
catch [Exception]
{
    Write-Host $_.Exception.Message
    exit 1
}


Can anybody give me an hint, how i can compare this two Folders?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Can you attach a log file for session, where it aborts without any error?
_________________
Martin Prikryl
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