EldoS | Feel safer!

Software components for data protection, secure storage and transfer

.Net sFTP File Length Property for Progress calculation

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#5019
Posted: 02/15/2008 09:14:36
by Jeremy Sullivan (Basic support level)
Joined: 02/15/2008
Posts: 6

I am using the .Net SFTPBlackbox, and I am wanting to know if there is a Property that I can call on the Uploading Thread to get the amount of data currently transferred to compare it against the total file size to populate a ProgressBar.

Thank you,
Jeremy Sullivan
#5020
Posted: 02/15/2008 09:38:39
by Eugene Mayevski (EldoS Corp.)

Request the file attributes (in your case, file size attribute) as described here before uploading the file.


Sincerely yours
Eugene Mayevski
#5021
Posted: 02/15/2008 10:06:04
by Jeremy Sullivan (Basic support level)
Joined: 02/15/2008
Posts: 6

No of the articles have a list of the specific attributes. Can you give me an example? For instance, can you fill in some sample code based on the code I wrote below:

Dim Client As TElSimpleSFTPClient

Try
Client.OpenFile(Filename As String, Mode As Integer, _
Attribute As SBSftpCommon.TElSftpFileAttributes)
Client.RequestAttribute(Filename As String, Mode As Integer, _
Attribute As SBSftpCommon.TElSftpFileAttributes)
Finally
Client.Close()
End Try


Thank you so much for your help.

#5022
Posted: 02/15/2008 10:24:02
by Eugene Mayevski (EldoS Corp.)

I am sorry but I have misread the question. I thought you need remote file size.

If you want to monitor the progress of the file upload/download operations, use OnProgress event.


Sincerely yours
Eugene Mayevski
#5027
Posted: 02/15/2008 11:54:27
by Jeremy Sullivan (Basic support level)
Joined: 02/15/2008
Posts: 6

Ok, thank you. Do you have any documentation or code samples for you using your classes with the OnProgress event?
#5028
Posted: 02/15/2008 12:18:15
by Eugene Mayevski (EldoS Corp.)

Documentation is installed when you install the evaluation version and is also available online (see here


Sincerely yours
Eugene Mayevski
#5029
Posted: 02/15/2008 12:39:36
by Jeremy Sullivan (Basic support level)
Joined: 02/15/2008
Posts: 6

Thanks. One last thing, Can you give me a code example to the the ReceiveAttributes method once I open a directory?
#5030
Posted: 02/15/2008 12:51:21
by Eugene Mayevski (EldoS Corp.)

Please try to write your own code using the above posted how-to article as a guideline. And we will correct the code if it doesn't work.


Sincerely yours
Eugene Mayevski
#5031
Posted: 02/15/2008 13:26:57
by Jeremy Sullivan (Basic support level)
Joined: 02/15/2008
Posts: 6

Ok, I understand that the following code sets up the Event and the Delegate. The SFTPObject.UploadFile triggers the Event. I'm assuming that I need to create a Sub that utilizes the data brought back, but how will the Delegate know what to call to update the ProgressBar? Do I need to create some sort of Do Loop so that the OnProgress will be constantly called until the uploading is done? I'm so sorry to be a pain. If I can get this cleared up, we are going to purchase the software from you guys. Here is code that I have so far:

--------------------------------------------------------

Code
    Dim Client As TElSimpleSFTPClient
    Friend WithEvents btnUpload As System.Windows.Forms.Button
    Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar


    Event OnProgress As TSBProgressEvent
    Delegate Sub TSBProgressEvent(ByVal Sender As Object, ByVal Total As Long, ByVal Current As Long, _
    ByRef Cancel As Boolean)  

    Sub Upload()

        ' Upload the file to SFTP server and optionally overwrite remote file if it exists
        Client.UploadFile(parLocalName, parRemoteFile, TSBSFTPFileTransferMode.ftmOverwrite)
    End Sub

    Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' set the license key. Trial license key is specified below.
        ' Trial key causes SecureBlackbox work slower.
        ' Request time-limited license key without delays on http://www.eldos.com/sbb/keyreq/
        SBUtils.Unit.SetLicenseKey("0190B807FC3C84EE4CAE3222EA8EBCC503B55E8ADEF669" _
        & "3234...C3F1" _
        & "E17B...3D1D" _
        & "49A2...0B82" _
        & "ACB5...2AF6" _
        & "D857...A7D1" _
        & "7D58...3783" _
        & "1EA712542B7784481C178E0789F29BC749773A")

        '' Parse the command line parameters
        'If Not ParseCommandLine() Then
        '    Return
        'End If

        ' create SFTP client component
        Client = New TElSimpleSFTPClient

        ' set connection parameters
        Client.Address = parAddress
        Client.Port = parPort
        Client.Username = parUsername
        Client.Password = parPassword

        ClientProgress = Client

        ' Perform the operation
        Try
            ' Connect to the SFTP server
            Client.Open()
            Try

                Client.OpenDirectory(parRemoteFolder)
                parLocalName = txtLocalFilename.Text
                Upload

            Finally
                ' Disconnect from the SFTP server
                Client.Close(False)
                lblOutput.Text = "File Uploaded Successfully."
            End Try

        Catch ex As Exception
            lblOutput.Text = ex.Message
        End Try

    End Sub

------------------------------------------------------------------------
#5032
Posted: 02/15/2008 13:47:27
by Eugene Mayevski (EldoS Corp.)

1) Are you talking about ActiveX and VB 6 or about VB.NET and .NET edition?

2) You don't need to open the directory before uploading the files.


Sincerely yours
Eugene Mayevski
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.

Reply

Statistics

Topic viewed 6093 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!