FileProgress only shows 0 or 1

Advertisement

JR_Baas
Joined:
Posts:
2

FileProgress only shows 0 or 1

I am trying to get a progress bar working with Access VBA. The file transfers correctly, but the FileProgress only shows 0 or 1.

The following code is my class module:
Option Compare Database
Option Explicit
Private WithEvents MySession As WinSCPnet.Session
Private Sub MySession_FileTransferProgress(ByVal sender, ByVal e As WinSCPnet.FileTransferProgressEventArgs)
  Dim progress As Double
  progress = e.FileProgress * 100#
  Debug.Print progress, e.CPS
End Sub
Public Sub OpenConnection(Protocol As WinSCPnet.Protocol, HostName As String, UserName As String, Password As String, SshHostKeyFingerprint As String)
  Set MySession = New WinSCPnet.Session
  Dim MySessionOptions As New WinSCPnet.SessionOptions
  With MySessionOptions
    .Protocol = Protocol
    .HostName = HostName
    .UserName = UserName
    .Password = Password
    .SshHostKeyFingerprint = SshHostKeyFingerprint
  End With
  
  MySession.Open MySessionOptions
End Sub
Public Sub UploadFile(LocalFileName As String, RemoteFileName As String)
 
  Dim MyTransferOptions As New WinSCPnet.TransferOptions
  Dim MyTransferResult As WinSCPnet.TransferOperationResult
  MyTransferOptions.TransferMode = TransferMode_Binary
  
  Set MyTransferResult = MySession.PutFiles(LocalFileName, RemoteFileName, False, MyTransferOptions)
  
  MyTransferResult.Check
 
End Sub
Public Sub CloseConnection()
  MySession.Dispose
End Sub

I am calling like this:
 Dim sftp As New clsWinSCP
  sftp.OpenConnection Protocol_Sftp, RemoteServer(2), RemoteUser(2), RemotePassword(2), "ssh-rsa 1024 c69mpwnBX+y3BE0t5zywJHyJOtx/xwzb+JmFHwTPIig="
  
  sftp.UploadFile LocalFilePath & "\" & fileName$, RemoteFilePath(2)
  
  sftp.CloseConnection

The debug output is:
 0             0 
 0             0 
 100           0 
 100           0 
 100           0 
 100           0

Any ideas?

Reply with quote

Advertisement

Hove
Joined:
Posts:
4

I use .NET c#, uploading larger files (MB and GB) and FileProgress always report only 0 and 1.

session.FileTransferProgress += (s, e) =>
    {
        if (fileTransferState.Canceled)
            e.Cancel = true;
 
        fileTransferState.BitesWritten = (long)(fileTransferState.StreamLength * e.FileProgress);
    };
session.PutFile(readStream, remotePath);

Reply with quote

Advertisement

You can post new topics in this forum