06-27-2012, 06:42 AM
Join Date: Mar 2009
Help me Return a String from a Function
I am working on this problem 4 hours now an i cant figure the right way out!
I have a class in this class i call a function which should return some string
the class connects to an ftp server and list the directory and returns the filenames of the dir.
Public Function GetFileList(ByVal host As String, ByVal username As String, ByVal password As String, ByVal currentdirectory As String) As List(Of String)
Dim oFTP As FtpWebRequest = CType(FtpWebRequest.Create(host & currentdirectory), FtpWebRequest)
oFTP.Credentials = New NetworkCredential(username, password)
oFTP.KeepAlive = True
oFTP.Method = WebRequestMethods.Ftp.ListDirectory
Dim response As FtpWebResponse = CType(oFTP.GetResponse, FtpWebResponse)
Dim sr As StreamReader = New StreamReader(response.GetResponseStream)
Dim str As String = sr.ReadLine
Dim oList As New List(Of String)
While str IsNot Nothing
If str.StartsWith(Data) Then
str = sr.ReadLine
oFTP = Nothing
so this should return all filenames of that directory
Now i have a form with a listview where i want to call this function and get the files of the "olist"
HOW CAN I DO THAT?!?! i mean how would my sub look like on my form where i want to call that function?