Topic "Directory contents are empty"

Author Message
[View user's profile]

Joined: 2013-10-31
Posts: 1

I'm using the standalone WinSCP with the .NET/Powershell extension in a powershell script. It works reasonably well, but there is sometimes a directory that WinSCP report as being empty (only consisting of ".."), when it is not.

Here is the example code I use:

. .\common.ps1
   Add-Type -Path "..\WinSCPnet.dll"
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions
    $sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
    $sessionOptions.HostName = ""
    $sessionOptions.UserName = "UserName"
    $sessionOptions.Password = "Password"
    $sessionOptions.SshHostKeyFingerprint = "ssh-dss 1024 asdfasdfasdfasdfasd random asdfasdfasdf"
      # Connect
      $session = New-Object WinSCP.Session
      $directoryInfo = $session.ListDirectory("/remote/directory/path")
      $dirFiles = $directoryInfo.Files
      #$dirFiles would only contain ".." if I iterated over it
      # Disconnect, clean up

    exit 0
catch [Exception]
    $_.Exception.Message | out-file $outputFp -encoding ascii -append
    exit 1

Curiously enough, when I ran most of this script by typing out lines (instead of running the script containing them), I think that directory's contents were shown to be correct. So I'm a little confused. Does anyone see any problem with the above code?
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26912
Location: Prague, Czechia
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you may email it to me. You will find my address (if you log in) in my forum profile. Please include link back to this topic in your email. Also note in this topic that you have emailed the log.

Martin Prikryl

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License