Help working from modules

whitezombie

Member
Joined
Jul 20, 2009
Messages
7
Programming Experience
10+
Hey folks, I am re-writing some code and I need to be able to do the same function in a module aspect as opposed to a FORM method. In my old code I for example got the directory contents and dumped it into a listbox. I need to now dump it into an array instead. Anyone have a good example of something like this? I need it to blinding get all the files regardless of filename or extension and dump them into an array.
 
Disregard, I found a solution.

VB.NET:
    Public Sub subCREATEARRAY()
        For Each foundFile As String In My.Computer.FileSystem.GetFiles("c:\temp\parse")
            arrFILES.Add(foundFile)
        Next
    End Sub
 
If you can't use the ReadOnlyCollection(Of String) that the GetFiles method returns you can convert it to a List(Of String) with the ToList extension method, or String array with the ToArray extension method.
VB.NET:
Dim A As ObjectModel.ReadOnlyCollection(Of String) = My.Computer.FileSystem.GetFiles("c:\temp\parse")
Dim B As List(Of String) = My.Computer.FileSystem.GetFiles("c:\temp\parse").ToList
Dim C() As String = My.Computer.FileSystem.GetFiles("c:\temp\parse").ToArray
 
Back
Top