file list and generics

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Why can't his work

Private Function GetFiles(ByVal sPath As String) As Generic.List(Of String)
Dim f() As String = Directory.GetFiles(sPath)
Return f()
End Function

Should I just create a File Class object, add to it's collection and then
return?

Thanks
 
So you want it as a List(of String)?

If so then convert the array to a List(of String):

Private Function GetFiles(ByVal sPath As String) As List(Of String)

Dim f() As String = Directory.GetFiles(sPath)

Return New List(Of String)(f)

End Function

or, more simply:

Private Function GetFiles(ByVal sPath As String) As List(Of String)

Return New List(Of String)(Directory.GetFiles(sPath))

End Function
 
Back
Top