_................................................. .........
Rudi's code from Rem 5R)
This works differently in a way I have never seen before. There is no need to call a "recursion Routine"
Initially The main Folder is "put" into a "Queue" ( at the " back " of it )
https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx
https://msdn.microsoft.com/de-de/lib...(v=vs.90).aspx
( I expect in the "Queue" is just holding the Pointer to the actual Folder Object
The code the does a similar For Next as in my Code. One major difference is that the first thing it does is at each Folder is to go through every Sub Folder therein and "Put" it at the "back" of the queue. It takes the current folder being "looked" at "out" of the Queue from the "front".
It effectively then "stacks up all" the Folders in the next level down. Eventually after it goes through every Folder in the current level it will reach the point where it starts on the next level. So effectively it does not go "back and forth" like mine does. Rather it has "looking up" or "back from the front" first all the first level Folders, then all the next level Folders , then all the next, and so on.
If you look at the difference in the output that I get from mine and Rudi's code, you will soon see the corresponding difference.
Again the tricky bit for me was to get a Variable to indicate the "level" or "column to the left".
What I do in this case is count every time a Sub Folder is put in the back of the Queue.
NxtLvlCnt
This will finally give an indication of the Number of Sub folders at the next level.
I have second count variable
CurrentLvlCnt
Which is originally set to the last level count ( set initially to one for the original main folder ), which is successively decreased each time a Folder is "taken out" of the queue. When it reaches zero it is an indication that we have reached the next series of Next level Sub Folders. When that occurs it is given the value of the next level Count, and the next level Cont is then reset to Zero.
_................................................. .......
For both code I finally added a bit of Error handling. I did this as when I tested with many real files , I often had an error if , for example the "doing stuff" involved opening a file. If this happens you are told what error occurred and to which file, then you go on to the next. ( I assume that errors do not occur in the original code that just Prints out the "explorer type" Listing. If it did I expect the output could go a bit out if step !! ) )
_...............................................
So I give here some typical output from a run of both codes. To make it a bit easier I include the example set of Folders I used. ( I hope they all come up. By me only a few Folders come up, although the are "indicted as all there " ? ? )
https://app.box.com/s/onj6ntvwkxbo1088x7e0tca2gst45hnq
( Edit : Here is another Folder to try https://app.box.com/s/9e6xnb65fijjhl7bk0q6gzzriihkzibw )
words I have a main
EileensFldr
That has three sub folders in it. Therein are files and further sub Folders and files etc…. as seen in the listing the Code gives.
Initially the code is set to run from a file in the same directory as folder EileensFldr




Reply With Quote
Bookmarks