Topic "Directory contents are empty"

Author Message
cny
[View user's profile]

Joined: 2013-10-31
Posts: 1
Hi,

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:

Code:

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

    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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
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
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