Re: GetDirectories Performance



Tom Scales wrote:
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@xxxxxx> wrote in message news:OJXiDUmZGHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
"Tom Scales" <tjscales@xxxxxxxxx> schrieb:
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:
Instead of populating the whole treeview control on startup, only add the nodes on the first level and check if the folders contain subfolders. If the latter is the case, add a dummy subnode to the node representing the folder. Then catch the node expand event and replace the dummy node with nodes for the actual files and folders contained in the folder. This should lead to acceptable performance and memory usage would be much lower than populating the whole control. In addition, in many cases it's very unlikely that the user will expand every single node and thus much less memory will be occupied by your application in total.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Unfortunately, that is essentially what I am doing. I am adding enough nodes to tell me if I need to add the + sign. That's where I get bitten, because the directory UNDER the one I am working with has 30,000+ files. GetDirectories must search every file to see if it is a directory. Very inefficience code on MS' part.


Tom, it sounds like you would be better served by doing P/Invoke via FindFirst and FindNext API calls. The way they work is through one file at a time, thus, you'll have much more control over your operation.

In addition, another thing that maybe slowing you down is the actual treeview (which is also very inefficient). I'd advise to you to devise a quick test to load 30,000 nodes and see how fast it is loading. You'll be surprised at how slow it will be. To get around this problem I went with a 3rd party tree list control from http://www.bennet-tec.com/ called TList. Their claim to fame is the speed and based on my usage it is not idle talk. It truly is pedal to the metal.

Regards






.



Relevant Pages

  • Re: Dont Administrators have access to everything?
    ... returning the folders to the Shared Documents folder, ... NO owner and no one has access to the files (not ... account had been granted Full Control, ... Owner's and Administrators' permissions. ...
    (microsoft.public.windowsxp.security_admin)
  • RE: Cant delete files.... constant permission popups!
    ... Administrator from taking Full Control of the entire folder and its contents, ... turn off UAC and try to copy or move folders. ... wants to master the full potential of Vista, such as UAC, that user will have ...
    (microsoft.public.windows.vista.administration_accounts_passwords)
  • Re: Dont Administrators have access to everything?
    ... returning the folders to the Shared Documents folder, ... NO owner and no one has access to the files (not ... account had been granted Full Control, ... Owner's and Administrators' permissions. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: (CStringList)...folder_list.Find(...) problem.
    ... I am trying to create a basic app with a treeview control that displays just ... the folders of the hard drive... ... Your "c_" prefix often means a member variable that is an MFC control, ...
    (microsoft.public.vc.mfc)
  • something stuck in memory and "Favorite folders"
    ... Neither is a major problem, ... whenever I now log off or restart my computer, the folders ... Secondly, somehow my name in parantheses [NEIL WOLLMAN], ... with brackets and in italics is stuck in memory some way. ...
    (microsoft.public.outlook)