GetDirectories Performance

Tech-Archive recommends: Fix windows errors by optimizing your registry



I'm writing a VB.NET 2003 program that uses a Treeview to display the drive
structure on the computer. I am having a major problem with performance.
The are many files on one drive (over a million) and it is killing me. For
example, one directory has a structure:

Main

------ Sub directory

-------------- 10 Sub directories, each with roughly 30,000 files.



When I execute this code on the Sub directory (i.e. strPath = SubDirectory)

'------------------------------------------------------------------------
Dim strPath As String = tn.FullPath ' Get the parent's path
Dim diDirectory As New DirectoryInfo(strPath)
Dim adiDirectories() As DirectoryInfo

Try

' Get an array of all sub-directories as DirectoryInfo objects.

adiDirectories = diDirectory.GetDirectories()

Catch exp As Exception

Exit Sub

End Try
'------------------------------------------------------------------------

it takes over 15 minutes to complete. This is on a P4-2.66 running XP Pro.

Any suggestions for improvement?

Thanks,

Tom




.



Relevant Pages