Hello everyone!
I would like to use the same code for copying files to an FTP server, and through USB. I've already written some code, which as of now uses functions from the System.IO
namespace.
To minimize code duplication, I've listed the functions which I need from the system.IO namespace, and I was thinking of designing an interface exposing similar functions, and then two classes, one for FTP file operations, and one for local ones.
I have a few questions about Interfaces though:
- Could design my interface so that the
File.*
andDirectory.*
organisation be preserved (so that routines declared in the interface follow the same hierarchy than in the IO namespace)? - Is there a way, for local operations, to just map functions from the IO namespace to the corresponding interface functions (writing something like
Sub IO.File.Delete Implements IOInterface.File_Delete
)? - Can I declare something like
Dim IOHandler As IOInterface
, assuming thatIOInterface
is the name of my interface? Can I then write bothIOHandler = New LocalIOHandler
andIOHandler = New FTPIOHandler
, assumingLocalIOHandler
andFTPIOHandler
are my two classes implementing theIOInterface
?
Thanks!
CFP.