Error Listing Directory - SynchronizeDirectories

Advertisement

rsford31
Joined:
Posts:
8

Error Listing Directory - SynchronizeDirectories

Hi,
I'm trying to use the SynchronizeDirectories() function from WinSCPnet.dll. I'm using PowerShell to sync the files. I'm currently running it from the Windows Powershell command line. When I run it I get the error "Error listing directory '/downloadfolder'".
The user id and password is an existing account that is being actively used by a user where they can connect and download files so I know it is accessible and that it works.

When logging in the root shows as e:/msl/privatemb/uploadfolder. "downloadfolder" is within the "uploadfolder" where the file are located.

I'm using the code from the sync example:

Add-Type -Path "E:\Program Files\WinSCP 5.13\WinSCPnet.dll"
 
# Session.FileTransferred event handler
 
function FileTransferred
{
    param($e)
 
    if ($e.Error -eq $Null)
    {
        Write-Host "Upload of $($e.FileName) succeeded"
    }
    else
    {
        Write-Host "Upload of $($e.FileName) failed: $($e.Error)"
    }
 
    if ($e.Chmod -ne $Null)
    {
        if ($e.Chmod.Error -eq $Null)
        {
            Write-Host "Permissions of $($e.Chmod.FileName) set to $($e.Chmod.FilePermissions)"
        }
        else
        {
            Write-Host "Setting permissions of $($e.Chmod.FileName) failed: $($e.Chmod.Error)"
        }
 
    }
    else
    {
        Write-Host "Permissions of $($e.Destination) kept with their defaults"
    }
 
    if ($e.Touch -ne $Null)
    {
        if ($e.Touch.Error -eq $Null)
        {
            Write-Host "Timestamp of $($e.Touch.FileName) set to $($e.Touch.LastWriteTime)"
        }
        else
        {
            Write-Host "Setting timestamp of $($e.Touch.FileName) failed: $($e.Touch.Error)"
        }
 
    }
    else
    {
        # This should never happen during "local to remote" synchronization
        Write-Host "Timestamp of $($e.Destination) kept with its default (current time)"
    }
}
# Main script
try
{
   $session = New-Object WinSCP.Session
     $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Ftp
        HostName = "hostname"
        UserName = "username"
        Password = "password"
      FtpSecure = [WinSCP.FtpSecure]::Implicit
      PortNumber = 990
        
    } 
   
    try
    {
      $session.SessionLogPath = "E:\TEMP\rsford31\logs\sessionlog.txt"
        # Will continuously report progress of synchronization
        $session.add_FileTransferred( { FileTransferred($_) } )
 
        # Connect
        $session.Open($sessionOptions)
 
        # Synchronize files
        $synchronizationResult = $session.SynchronizeDirectories(
            [WinSCP.SynchronizationMode]::Local, "/downloadfolder", "E:\TEMP\rsford31", $False)
 
        # Throw on any error
        $synchronizationResult.Check()
    }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    exit 0
}
catch
{
    Write-Host "Error: $($_.Exception.Message)"
    exit 1
}
Here is a snippet from the logs:

< 2018-07-24 11:30:40.652 200 Command accepted, PBSZ=0
> 2018-07-24 11:30:40.652 PROT P
< 2018-07-24 11:30:40.652 200 Command okay.
. 2018-07-24 11:30:40.652 Connected
. 2018-07-24 11:30:40.652 --------------------------------------------------------------------------
. 2018-07-24 11:30:40.652 Using FTP protocol.
. 2018-07-24 11:30:40.652 Doing startup conversation with host.
> 2018-07-24 11:30:40.652 PWD
< 2018-07-24 11:30:40.652 257 "E:/MSL/PrivateMB/uploadfolder" is current directory.
. 2018-07-24 11:30:40.668 Getting current directory name.
. 2018-07-24 11:30:40.668 Startup conversation with host finished.
< 2018-07-24 11:30:40.668 Script: Active session: [1] userid@ftpurl
> 2018-07-24 11:30:41.073 Script: pwd
< 2018-07-24 11:30:41.073 Script: E:/MSL/PrivateMB/uploadfolder
> 2018-07-24 11:30:41.214 Script: synchronize local   -nopermissions -preservetime -transfer="binary" -criteria="time" -- "/downloadfolder" "E:\TEMP\rsford31"
< 2018-07-24 11:30:41.214 Script: Comparing...
. 2018-07-24 11:30:41.214 Collecting synchronization list for local directory '/downloadfolder' and remote directory 'E:\TEMP\rsford31', mode = Local, params = 0x2 (NoConfirmation)
* 2018-07-24 11:30:41.214 (EOSEtxtException) Error retrieving file list for "/downloadfolder\*.*".
* 2018-07-24 11:30:41.214 System Error.  Code: 3.
* 2018-07-24 11:30:41.214 The system cannot find the path specified
. 2018-07-24 11:30:41.214 Asking user:
. 2018-07-24 11:30:41.214 Error listing directory '/downloadfolder'. ("Error retrieving file list for ""/downloadfolder\*.*"".","System Error.  Code: 3.","The system cannot find the path specified")
< 2018-07-24 11:30:41.214 Script: Error listing directory '/downloadfolder'.
< 2018-07-24 11:30:41.214 Script: Error retrieving file list for "/downloadfolder\*.*".
< 2018-07-24 11:30:41.214 System Error.  Code: 3.
< 2018-07-24 11:30:41.214 The system cannot find the path specified
< 2018-07-24 11:30:41.214 Script: Error listing directory '/downloadfolder'.
< 2018-07-24 11:30:41.214 Script: Error retrieving file list for "/downloadfolder\*.*".
< 2018-07-24 11:30:41.214 System Error.  Code: 3.
< 2018-07-24 11:30:41.214 The system cannot find the path specified
. 2018-07-24 11:30:41.214 Script: Failed
> 2018-07-24 11:30:41.354 Script: exit
. 2018-07-24 11:30:41.354 Script: Exit code: 1
. 2018-07-24 11:30:41.370 Disconnected from server
I've attached the full logs. Not sure what I'm doing wrong...
  • sessionlog.txt (6.47 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
28,809
Location:
Prague, Czechia

Re: Error Listing Directory - SynchronizeDirectories

rsford31 wrote:

I'm currently running it from the Windows Powershell command line. When I run it I get the error "Error listing directory '/downloadfolder'".
The user id and password is an existing account that is being actively used by a user where they can connect and download files so I know it is accessible and that it works.

Then logging in the root shows as e:/msl/privatemb/uploadfolder. "downloadfolder" is within the "uploadfolder" where the file are located.
When you have to use e:/msl/privatemb/uploadfolder/downloadfolder not /downloadfolder.

Reply with quote

rsford31
Joined:
Posts:
8

Re: Error Listing Directory - SynchronizeDirectories

martin wrote:

rsford31 wrote:

I'm currently running it from the Windows Powershell command line. When I run it I get the error "Error listing directory '/downloadfolder'".
The user id and password is an existing account that is being actively used by a user where they can connect and download files so I know it is accessible and that it works.

When logging in the root shows as e:/msl/privatemb/uploadfolder. "downloadfolder" is within the "uploadfolder" where the file are located.
Then you have to use e:/msl/privatemb/uploadfolder/downloadfolder not /downloadfolder.

Yup! Tried that! Tried e:\msl\privatemb\uploadfolder\downloadfolder, \privatemb\uploadfolder\downloadfolder and \downloadfolder. I get the same error message.

I did figure it out though by going through the logs more closely. I had the parameters for the local and remote directories mixed up. Thanks!

Reply with quote

Advertisement

You can post new topics in this forum