|
-
Mar 14th, 2008, 05:51 PM
#1
Thread Starter
New Member
[2005] Application freeze
Hello,
I am using the following script to browse to a folder and subfolders to search for files with a specific file-extension.
The problem is, if I have a directory with some subfolders and a large number of files with that extension, everything goes fine.
When make the script search a entire partition (not my windows partition), the application freezes, but it is still searching (HDD LED flickers).
I am looking for a solution, because I want the user to be able to see which directory the script is currently searching, and to display a cancel button, which now cannot be pushed while the application will freeze.
Does anyone know a solution for my problem?
This is the script I am using.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Int32
Call searchFiles("E:", "*.extension")
For i = 0 To Files.GetUpperBound(0) - 1
ListBox1.Items.Add(Files(i))
Next
End Sub
Private Files() As String
Private Counter As Int32
Private Sub searchFiles(ByRef sPath As String, ByRef FileSpec As String)
Dim Dir As String
Dim file As String
If sPath.Substring(sPath.Length - 1) <> "\" Then
sPath &= "\"
End If
Dim files() As String = Directory.GetFiles(sPath)
For Each file In files
If file.ToLower Like FileSpec Then
ReDim Preserve files(Counter)
files(Counter) = file
Counter += 1
End If
Next
Dim dirs() As String = Directory.GetDirectories(sPath)
For Each Dir In dirs
Call searchFiles(Dir, FileSpec)
Next
End Sub
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|