I'm writing a wrapper class to expose a subset of the functionality of a .NET FTP library edtftpne from Enterprise Distributed Technologies.
When you call the edtftp's GetFileInfos method you get an array of FTPFile objects returned. I'm able to iterate through these but I don't know how to pass them on as a new and different object array containing only Name and Size for each file. Here's the code I have. Sorry it's a little confusing because I have my own class named FTPFile and the .NET library I'm using also has a class named FTPFile. I'm using both of them here. I should probably change the name of my class just to avoid confusion:
Public Function GetFileList() As FTPFile() Implements IFTP.GetFileList
Dim ftpfiles() As EnterpriseDT.Net.Ftp.FTPFile
ftpfiles = fCon.GetFileInfos 'Fill object array
Dim f As EnterpriseDT.Net.Ftp.FTPFile
Dim t As FTPFile = New FTPFile 'My custom class to hold FileName and FileSize for Each file
For Each f In ftpfiles
'What do I do here to put these in my GetFileList array?
Next
End Function
I'm also baffled on how to write my own FTPFile class so that this function can assign properties to each object it creates but the external COM code will see the properties of my FTPFile class as ReadOnly.
Here's what my FTPFile class looks like:
Public Interface IFTPFile
ReadOnly Property FileSize() As Long
ReadOnly Property FileName() As String
End Interface
<ClassInterface(ClassInterfaceType.None)> _
Public Class FTPFile : Implements IFTPFile
Private sFileName As String = ""
Private lFileSize As Long
Public ReadOnly Property FileName() As String Implements IFTPFile.FileName
Get
FileName = sFileName
End Get
'Set(ByVal value As String)
' sFileName = value
'End Set
End Property
Public ReadOnly Property FileSize() As Long Implements IFTPFile.FileSize
Get
FileSize = lFileSize
End Get
'Set(ByVal value As Long)
' lFileSize = value
'End Set
End Property
End Class
Maybe I'm going about this totally wrong. I'd just pass on the object array that I'm getting from the GetFileInfos method but COM clients won't have access to the class/object EnterpriseDT.Net.Ftp.FTPFile without me rewriting it, I'm assuming.
Imports MyFTPFile = EnterpriseDT.Net.Ftp.FTPFile;