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

martin
Site Admin
martin avatar
Joined:
Posts:
34,115
Location:
Prague, Czechia

Re: FileProgress only shows 0 or 1

How large are the files? How long does it take to transfer one file?

Reply with quote

Advertisement

You can post new topics in this forum