Jump to content


Photo

Implementing FTP and SFTP in one application


  • Please log in to reply
1 reply to this topic

#1 m.gunesch

m.gunesch
  • Members
  • 16 posts

Posted 05 February 2009 - 12:00 PM

Hi everybody,

I have a question according to ftp/sftp with SmartFTP-Library.
I'd like to create an VB6 application which can do file transfer via ftp and sftp. This should be controlled via a flag in an ini file.

My question is, what is the best way to do that?
I have already implemented FTP, but now, when I try to use SFTP I have some problems with missing methods or also same function name but different parameters.

e.g.:
ChangeDirectory doensn't exist with SFTP
ftp UploadFile has differnt parameters than sftp UploadFile

I'd like to use the same object and just at time of creation I'd like to decide what I have to create, like this:

If SFTP Then
Set objFTP = CreateObject("sfFTPLib.SFTPConnection")
Else
Set objFTP = CreateObject("sfFTPLib.FTPConnectionSTA")
End If

It would be possible to define 2 different objects, but than I would have to use different ways for e.g. up-/downloading a file??
Or is there a better way to do that?

Thanks in advance!

Bye, Markus

#2 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 05 February 2009 - 02:42 PM

You have to make 2 implementations. One for FTP and one for SFTP. The best way is to introduce a new abstraction layer. E.g. create an abstract base class Connection and then implement two concrete classes FTPConnection ans SFTPConnection. However I do not know what OOP features VB6 offers. I strongly recommend to use VB.NET or C# if you have the choice.

Regards,
Mat




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users