VB.NET Progress Bar - Recursive Search

  • Thread starter Thread starter Gabe Matteson
  • Start date Start date
G

Gabe Matteson

I am trying to set the maximum value of the progress bar so that when a user
searches through the specified directory they can see their status. the
progress bar name is on form2 and is named progstatus. Does anyone know how
to set this up with the code below? appreciate it. thank you.





Private Function Dir(ByVal sDir As String)

Try

Dim strDir As String

Windows.Forms.Cursor.Current = Cursors.WaitCursor

For Each strDir In System.IO.Directory.GetDirectories(sDir)

If blnClosed = True Then

Return intDirCount

Exit Function

End If

Dir(strDir)

intDirCount = intDirCount + 1

Next

Return intDirCount

Windows.Forms.Cursor.Current = Cursors.Arrow

Catch ex As Exception

Return intDirCount

Windows.Forms.Cursor.Current = Cursors.Arrow

MsgBox(ex, MsgBoxStyle.Information, "Exception")

End Try

End Function





Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnQuery.Click

intDirCount = 0

Dim strResults As String = Dir(Trim(LCase(txtDirSource.Text)))



MsgBox("Number of Directories: " & strResults, MsgBoxStyle.Information,
"Query Statistics")

End Sub
 
Didn't quite follow the details of what you are doing, but here is something
similar I have used that mght help. Here I was sifting through files in a
folder looking for the newest one.



With ProgressBar

.Maximum = My.Computer.FileSystem.GetFiles(SourcePath).Count

.Minimum = 0

.Step = 1

.Value = 1

End With

For Each foundFile As String In My.Computer.FileSystem.GetFiles(SourcePath)

Me.ProgressBar.PerformStep()

'-- do some stuff.

Next
 
awesome, thanks!
you wouldn't happen to know how to incorporate the maximum to = that of all
directories and files?.. again, thanks!
 
more or less, i have the program searching through a file system to return a
list of files and folders that have not been accessed in a certain period of
time. i want to be able to get a total count of the items in a specified
directory and have the progressbar keep track of the recursive search
status, so the max. value would equal the number of items in a directory...
 
Back
Top