ckelsoe
Member
I have a function that returns an array list. The function looks something like this:
Protected Function RetrieveExtensions(ByVal sourceDir As System.IO.DirectoryInfo) As ArrayList
Dim file As System.IO.FileInfo
Dim strExtension As String
Dim childDir As System.IO.DirectoryInfo
For Each file In sourceDir.GetFiles()
strExtension = file.Extension
RetrieveExtensions.Add(strExtension) ' Code fails here
Next
For Each childDir In sourceDir.GetDirectories()
RetrieveExtensions(childDir)
Next
End Function
The problem I am having is that I get the error "Object reference not set to an instance of an object." when the code hits the line marked above. So far I am unable to understand why this would fail. It works in a normal arraylist.
Thanks for any help in advance.
Charles
Protected Function RetrieveExtensions(ByVal sourceDir As System.IO.DirectoryInfo) As ArrayList
Dim file As System.IO.FileInfo
Dim strExtension As String
Dim childDir As System.IO.DirectoryInfo
For Each file In sourceDir.GetFiles()
strExtension = file.Extension
RetrieveExtensions.Add(strExtension) ' Code fails here
Next
For Each childDir In sourceDir.GetDirectories()
RetrieveExtensions(childDir)
Next
End Function
The problem I am having is that I get the error "Object reference not set to an instance of an object." when the code hits the line marked above. So far I am unable to understand why this would fail. It works in a normal arraylist.
Thanks for any help in advance.
Charles