SmartFTP Library VB error 17

This forum is not monitored by the SmartFTP staff. If you have a license please contact technical support by email.
Post Reply
bmangold
Posts: 2
Joined: Wed Jul 06, 2005 7:57 pm

SmartFTP Library VB error 17

Post by bmangold » Wed Jul 06, 2005 8:02 pm

I have purchased and installed the license but am still receiving errors when attempting to connect via VB. The code I am using is below. It worked fine last week, before the free-trial expired.

Thanks.

Code: Select all




    'Early Binding "Dual Interface"



    'Note: Force the compiler to use the dual interface if available



    Set objFTP = CreateObject("sfFTPLib.FTPConnection")



    



    'Early Binding "Mid Level"



    'Note: The compiler may use the dual interface



    'Set objFTP = New sfFTPLib.FTPConnection



    



    objFTP.Host = "xx.xx.xx.xx"



    objFTP.Port = 21



    objFTP.Protocol = ftpProtocolNormal 'ftpProtocolSSLExplicit



    objFTP.Username = "xxxxx"



    objFTP.Password = "xxxxx"



    objFTP.Passive = True



    objFTP.LogFile = pwd & "ftp.log"



    



    If objFTP.Connect = sfFTPLib.enumError.ftpErrorSuccess Then



        MsgBox ("Connected to " & objFTP.Host)



        If objFTP.ChangeDirectory("/xxxxx") = sfFTPLib.enumError.ftpErrorSuccess Then



            MsgBox ("ChangeDirectory() successful. (" & objFTP.WorkingDirectory & ")")







            ' Upload File



            Dim nRestart



            nRestart = 0







            Dim strMsg



            If objFTP.UploadFile32(pwd & "xxxxx.xml", "xxxxx.xml", nRestart) = sfFTPLib.enumError.ftpErrorSuccess Then



                strMsg = "UploadFile32() successful." & vbCrLf



                strMsg = strMsg & "LastTransferBytes = " & objFTP.LastTransferBytes32 & " B" & vbCrLf



                strMsg = strMsg & "LastTransferTime = " & objFTP.LastTransferTime & " s" & vbCrLf



                strMsg = strMsg & "LastTransferSpeed = " & objFTP.LastTransferSpeed & " B/s"



                MsgBox (strMsg)



            Else



                strMsg = "UploadFile32() failed. LastError = " & objFTP.LastError & vbCrLf



                strMsg = strMsg & "LastReplyCode = " & objFTP.LastReplyCode & vbCrLf



                strMsg = strMsg & "LastReply = " & objFTP.LastReply & vbCrLf



                MsgBox (strMsg)



            End If



            



            ' Read Directory



            If objFTP.ReadDirectory() = sfFTPLib.enumError.ftpErrorSuccess Then



                Dim objDirectory As sfFTPLib.FTPDirectory



                Set objDirectory = objFTP.Directory



                Dim objItem As sfFTPLib.FTPItem



                Dim strList



                For Each objItem In objDirectory



                    strList = strList & "Type=" & objItem.Type & "; Name=" & objItem.Name & "; Size=" & objItem.Size32 & "; Date=" & Format(objItem.Date, "MM/DD/YYYY HH:NN:SS") & vbCrLf



                Next



                MsgBox (strList)



            Else



                MsgBox ("ReadDirectory() failed. LastError = " & objFTP.LastError)



            End If



        Else



            MsgBox ("ChangeDirectory() failed. LastError = " & objFTP.LastError)



        End If



        



    Else



        MsgBox ("Connect() failed. LastError = " & objFTP.LastError)



    End If




mb
Posts: 12026
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: SmartFTP Library VB error 17

Post by mb » Wed Jul 06, 2005 10:09 pm

You need to call LoadLicenseKeyFile or LoadLicenseKeyData to load your license key.

Regards,
-Mat

bmangold
Posts: 2
Joined: Wed Jul 06, 2005 7:57 pm

Re: SmartFTP Library VB error 17

Post by bmangold » Wed Jul 06, 2005 10:12 pm

What should the argument be, I couldn't find a good example online.

-Bob

mb
Posts: 12026
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: SmartFTP Library VB error 17

Post by mb » Wed Jul 06, 2005 11:41 pm

Please see the help file. Its the sfFTPLib.chm. You should also find a few examples in the SamplesScript directory.

Code: Select all

'///////////////////////////////////////////////////////////////////////////////////



'//



'// LoadLicenseKeyData v1.0 (9. May 2005)



'//



'// Purpose: 



'//   Shows how to load the license key from a string.



'//



'// Copyright (c) 2005 by SmartFTP.com



'//



'///////////////////////////////////////////////////////////////////////////////////







Dim strKey







strKey = strKey & "-----BEGIN KEY-----" & vbCrLf



strKey = strKey & "Product: SmartFTP FTP Library" & vbCrLf



strKey = strKey & "ID: 400000000" & vbCrLf



strKey = strKey & "User: user" & vbCrLf



strKey = strKey & "Company: my company" & vbCrLf



strKey = strKey & "Email: user@host.com" & vbCrLf



strKey = strKey & "Version: 1.0" & vbCrLf



strKey = strKey & "Number of Users: 1" & vbCrLf



strKey = strKey & "Date of Issue: 2005-04-05" & vbCrLf



strKey = strKey & "Maintenance Expiration: 2006-04-05" & vbCrLf



strKey = strKey & "-----BEGIN SIGNATURE-----" & vbCrLf



strKey = strKey & "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" & vbCrLf



strKey = strKey & "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" & vbCrLf



strKey = strKey & "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" & vbCrLf



strKey = strKey & "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" & vbCrLf



strKey = strKey & "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==" & vbCrLf



strKey = strKey & "-----END SIGNATURE-----" & vbCrLf







Dim obj



Set obj = CreateObject("sfFTPLib.FTPConnection")







WScript.Echo "Object created." & vbCrLf







WScript.Echo strKey







If obj.LoadLicenseKeyData(strKey) Then



	WScript.Echo "Success"



Else



	WScript.Echo "Failed"



End If
Regards,
-Mat

Post Reply