Page 1 of 2
FindFirst-FindNext
Posted:
Sun Oct 13, 2013 2:35 pm
by Slowdown
I'm troubled.
Code:
- Code: Select all
Public Sub FindDirs(SearchPath As String)
Dim AllDirectorys As Strings = Dir.FindFile(SearchPath & "/", "*", "System;Hidden;AllDirs")
For Each Directory As String in AllDirectorys
If Dir.IsDir(Directory) = True Then
ListBox1.Append(Directory)
DoEvents()
SourceDirLab.Caption = Str(ListBox1.Length())
DoEvents()
FindNextDirs(Directory)
End If
Next
End Sub
Public Sub FindNextDirs(SearchPath As String)
Dim AllDirectorys As Strings = Dir.RecursiveFindFile(SearchPath & "/", "*", "System;Hidden;AllDirs")
For Each Directory As String in AllDirectorys
If Dir.IsDir(Directory) = True Then
ListBox1.Append(Directory)
DoEvents()
SourceDirLab.Caption = Str(ListBox1.Length())
DoEvents()
End If
Next
End Sub
Calling it,
- Code: Select all
FindDirs("C:/Windows")
9 out of 10 runs KBasic will report,
- Unknow Exception.png (11 KiB) Viewed 243 times
Deleting the Cache does not help.
In my opinion it works or it doesn't, but not sometime it does and sometime it doesn't
- diskus.gif (14.66 KiB) Viewed 243 times
Re: FindFirst-FindNext
Posted:
Sun Oct 13, 2013 5:41 pm
by Henning
Hhmmmm...
Created a new project, and copied your code. Changed the FormName to fit.
It works every time as expected, 745 entries in the ListBox...
- Code: Select all
'Sub Form_OnOpen()
' ListBox1.RemoveAll
' FindDirs("C:/Windows")
'End Sub
'
Public Sub FindDirs(SearchPath As String)
Dim AllDirectorys As Strings = Dir.FindFile(SearchPath & "/", "*", "System;Hidden;AllDirs")
For Each Directory As String in AllDirectorys
If Dir.IsDir(Directory) = True Then
ListBox1.Append(Directory)
DoEvents()
frmMain.Caption = Str(ListBox1.Length())
DoEvents()
FindNextDirs(Directory)
End If
Next
End Sub
Public Sub FindNextDirs(SearchPath As String)
Dim AllDirectorys As Strings = Dir.RecursiveFindFile(SearchPath & "/", "*", "System;Hidden;AllDirs")
For Each Directory As String in AllDirectorys
If Dir.IsDir(Directory) = True Then
ListBox1.Append(Directory)
DoEvents()
frmMain.Caption = Str(ListBox1.Length())
DoEvents()
End If
Next
End Sub
Private Sub CommandButton1_OnEvent()
ListBox1.RemoveAll
FindDirs("C:/Windows")
frmMain.Caption = Str(ListBox1.Length()) & " DONE!"
End Sub
/Henning
Re: FindFirst-FindNext
Posted:
Sun Oct 13, 2013 7:00 pm
by Slowdown
It's frustrating me.
Certainly because it's code i have used in the past and it worked without problems.
I have started a few day's ago and the problems started, stripped all the code till the code i listed
and keep the same problems.
I have directory's with more than 20k entry's and one moment it runs fine and the second try bingo again KBasic unknow exception.
Take a much smaller directory and the same problem.
When ported the code to Q7Basic i can easily use FindDirs("C:/") it runs without problems every time.
Use the latest version of KB (5 okt 2010).
i'm out of options.
Re: FindFirst-FindNext
Posted:
Mon Oct 14, 2013 1:18 pm
by Slowdown
Because i was out of options i did install a fresh copy of Windows XP.
sadly no luck, it seems that at the first glance it solved my problems but when reading a somewhat bigger directory
i got the same error.
Re: FindFirst-FindNext
Posted:
Mon Oct 14, 2013 6:39 pm
by Henning
Thinking loud...
Could it be somthing with VBox, as I understand it youre running XP in a VM....
My kbrun.exe is dated 2010-10-21
/Henning
Re: FindFirst-FindNext
Posted:
Tue Oct 15, 2013 5:25 am
by Slowdown
You could have a valid point Henning,
I don't have Windows hardware anymore started in 2006 with the mac.
But do have older realeses of Virtualbox, will try and let you know.
Re: FindFirst-FindNext
Posted:
Tue Oct 15, 2013 9:48 am
by Slowdown
Did try some older releases of VB but still no luck.
I'll let it rest.
Re: FindFirst-FindNext
Posted:
Tue Oct 15, 2013 1:03 pm
by Slowdown
I didn't let it rest, tried it on Windows 7
I now have reclaimed 25 GB
The first 300 directory's where no problem but after the aprox. 300 directory's
the directory's where read in by 1 in each 3 or 4 minutes
Now i'll let it rest.
Re: FindFirst-FindNext
Posted:
Tue Oct 15, 2013 8:57 pm
by Henning
How much RAM have you allocated for XP in the VM?
745 entries in my app in < 5 sec.
/Henning
Re: FindFirst-FindNext
Posted:
Wed Oct 16, 2013 10:20 am
by Slowdown
In VB i have 2GB allocated for XP.
The speed isn't a problem with XP that problem i encountered with Windows 7 (64 bit)
If it's not crashing i can read 40K directory's in 11 seconds
I'm now testing nearly the same code in Q7B, so far no crashing.