Link to home
Start Free TrialLog in
Avatar of nickmarshall
nickmarshall

asked on

Not declared

Hi,

I get the following error about not being declared;

lstFilesFound

on line that reads

lstFilesFound.Add(f)

Here is the code...

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        searchFiles()

    End Sub

    Private Sub searchFiles()
        Try
            Dim drives() As String
            Dim rootfolders() As String
            Dim d As String
            Dim f As String
            drives = System.IO.Directory.GetLogicalDrives()
            For drivecount As Integer = 0 To drives.Length - 1
                rootfolders = System.IO.Directory.GetDirectories(drives(drivecount))
                For rootFolderCount As Integer = 0 To rootfolders.Length - 1
                    DirSearch(rootfolders(rootFolderCount))
                Next
            Next
        Catch ex As Exception

        End Try
    End Sub

    Sub DirSearch(ByVal sDir As String)
        Dim d As String
        Dim f As String
        Try
            For Each d In System.IO.Directory.GetDirectories(sDir)
                For Each f In System.IO.Directory.GetFiles(d, "*.Txt")
                    lstFilesFound.Add(f)
                Next
                DirSearch(d)
            Next
        Catch excpt As System.Exception
            Debug.WriteLine(excpt.Message)
        End Try
    End Sub
End Class
Avatar of apresto
apresto
Flag of Italy image

Hi nickmarshall,

You havent declared lstFilesFound, what should it be, an arraylist?

if so add it at the top where you have the other DIM lines, Dim lstFilesFound as ArrayList or something similar

Apresto
ASKER CERTIFIED SOLUTION
Avatar of apresto
apresto
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial