Need Fast Algorithm To Duplicate Tree Structure 
Author Message
 Need Fast Algorithm To Duplicate Tree Structure

I want to be able to create a tree structure identical to whatever
files/directories are dragged onto my TreeView.  The way I do it now is to
create a FileSystem object for each item that is dragged and, if it's a
file, just create the file node, and if it's a directory, add the directory
node and recursively add any subdirectories and file nodes.  This works.
However, it's performance is bad when dealing with thousands of
files/directories and especially when the source is on a network location.
Had the source been another TreeView, I could easily just copy the nodes but
the data is transmitted by the DragDrop event with the Data object and thus
is not possible.  Anyone know of a good way to do this?

-Matt Thalman

Great Plains Software



Fri, 17 May 2002 03:00:00 GMT  
 Need Fast Algorithm To Duplicate Tree Structure
An equally helpful thing would be if I had a way to list all files within a
directory including the subdirectories using API calls.  I have seen API
calls that will retrieve all files within a drive.  Anyone know if there is
a way to specify a directory?

Thanks,

Matt Thalman

Great Plains Software


Quote:
> I want to be able to create a tree structure identical to whatever
> files/directories are dragged onto my TreeView.  The way I do it now is to
> create a FileSystem object for each item that is dragged and, if it's a
> file, just create the file node, and if it's a directory, add the
directory
> node and recursively add any subdirectories and file nodes.  This works.
> However, it's performance is bad when dealing with thousands of
> files/directories and especially when the source is on a network location.
> Had the source been another TreeView, I could easily just copy the nodes
but
> the data is transmitted by the DragDrop event with the Data object and
thus
> is not possible.  Anyone know of a good way to do this?

> -Matt Thalman

> Great Plains Software



Fri, 17 May 2002 03:00:00 GMT  
 Need Fast Algorithm To Duplicate Tree Structure
Check out VBNet at http://www.mvps.org/vbnet .  I think you'll find what you
are looking for... or at least a good start.


Quote:
> An equally helpful thing would be if I had a way to list all files within
a
> directory including the subdirectories using API calls.  I have seen API
> calls that will retrieve all files within a drive.  Anyone know if there
is
> a way to specify a directory?

> Thanks,

> Matt Thalman

> Great Plains Software



> > I want to be able to create a tree structure identical to whatever
> > files/directories are dragged onto my TreeView.  The way I do it now is
to
> > create a FileSystem object for each item that is dragged and, if it's a
> > file, just create the file node, and if it's a directory, add the
> directory
> > node and recursively add any subdirectories and file nodes.  This works.
> > However, it's performance is bad when dealing with thousands of
> > files/directories and especially when the source is on a network
location.
> > Had the source been another TreeView, I could easily just copy the nodes
> but
> > the data is transmitted by the DragDrop event with the Data object and
> thus
> > is not possible.  Anyone know of a good way to do this?

> > -Matt Thalman

> > Great Plains Software



Sat, 18 May 2002 03:00:00 GMT  
 Need Fast Algorithm To Duplicate Tree Structure

' this will enumerate the subject folder.
hSearch = FindFirstFile(...)
If hSearch <> INVALID_HANDLE_VALUE then
    Do
        ' add nodes to your tree or something

        Success = FindNextFile
        If not Success then exit do

        ' if it's a directory then you could make a recursive call.
        ' The problem with that approach is that you would probably
        ' blow the VB stack if it's a complex directory structure.

    Loop

End if

That's the easy way. A better way would be to enumerate via
IShellFolder. You can find such examples in Bruce McKinney's book. You
could also use the same technique using the FileSystemObject in the
Microsoft Scripting Runtime (SCRRUN.DLL), but I never used it.



Quote:
> I want to be able to create a tree structure identical to whatever
> files/directories are dragged onto my TreeView.  The way I do it now
is to
> create a FileSystem object for each item that is dragged and, if it's
a
> file, just create the file node, and if it's a directory, add the
directory
> node and recursively add any subdirectories and file nodes.  This
works.
> However, it's performance is bad when dealing with thousands of
> files/directories and especially when the source is on a network
location.
> Had the source been another TreeView, I could easily just copy the
nodes but
> the data is transmitted by the DragDrop event with the Data object
and thus
> is not possible.  Anyone know of a good way to do this?

> -Matt Thalman

> Great Plains Software

--
Monte Hansen
VB Yuk Yuk

Sent via Deja.com http://www.deja.com/
Before you buy.



Sun, 19 May 2002 03:00:00 GMT  
 Need Fast Algorithm To Duplicate Tree Structure
You also should lock the treeview window.

Public Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As
Long) As Long

When done updating pass a 0 for the hwnd to release the lock


Quote:
> I want to be able to create a tree structure identical to whatever
> files/directories are dragged onto my TreeView.  The way I do it now is to
> create a FileSystem object for each item that is dragged and, if it's a
> file, just create the file node, and if it's a directory, add the
directory
> node and recursively add any subdirectories and file nodes.  This works.
> However, it's performance is bad when dealing with thousands of
> files/directories and especially when the source is on a network location.
> Had the source been another TreeView, I could easily just copy the nodes
but
> the data is transmitted by the DragDrop event with the Data object and
thus
> is not possible.  Anyone know of a good way to do this?

> -Matt Thalman

> Great Plains Software



Mon, 20 May 2002 03:00:00 GMT  
 Need Fast Algorithm To Duplicate Tree Structure
Quote:
> You also should lock the treeview window.

> Public Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As
> Long) As Long

It is *very* inadvisable to use LockWindowUpdate for this... in fact, I
don't think that general applications are supposed to use it at all. Sending
a WM_SETREDRAW message is the recommended method.

--
Ben Baird, Microsoft MVP
Visual Basic Thunder
http://www.vbthunder.com
Please keep your programming questions on the newsgroups.



Mon, 20 May 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. need to duplicate Outlook97's folder tree look

2. If you need fastest Tree/Grid/List

3. VBA or VB tree Algorithm

4. Very fast sorting algorithm

5. Fast algorithm to generate pi?

6. Fast algorithm to generate pi?

7. Know of a fast image rotate algorithm?

8. Fast Sorting Algorithm (code supplied)

9. Algorithm/data structure library available?

10. Data structures and algorithms in VB?

11. ! How to duplicate database structure

12. Duplicating a form structure

 

 
Powered by phpBB® Forum Software