Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: WinSCP dll (powershell) putfiles long path name

WinSCP should support long paths. Make sure you have the latest version of WinSCP:

Though it can also be a server-side limitation.
Hard to tell without see an exact error message or even better a session log file (Session.SessionLogPath).

WinSCP dll (powershell) putfiles long path name

I created a powershell script to transfer files from local path to remote path, when the file path is greater than 260 winscp throws exception and stops transfer, my question is can i ignore the error of long path name and continue transfer the rest of files? also i tried to get all the files less than 250 characters but it doesn't work.
here is my script, thanks

param (
    $localPath = "F:\Test1\*",
    $remotePath = "/Test1"
    # Load WinSCP .NET assembly
    Add-Type -Path "WinSCPnet.dll"
    # Setup session options
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = ""
        UserName = "ftpuser"
        Password = "eight*eight=64"
        SshHostKeyFingerprint = "ssh-rsa 1024 2i34SDb4+UdjGY8D20qJpbiTWP9Vly51ILjGN96/5bY="
    $session = New-Object WinSCP.Session
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
        # Connect
        $files=(Get-ChildItem -Path $localPath -Recurse | where {$_.fullname.Length -lt 250})
        foreach ($Fileinfo in $files) {
           $session.PutFiles($Fileinfo.FullName , $remoteFilePath)
               Write-Host ($Fileinfo.FullName)
    Write-Host $_.Exception.Message
    exit 1