03-04-2016 04:47 AM
Hi,
is there a reason why Recursive File List.vi is returning the input folder path in "All folders" output? I can see in the code that it is added at the beginning but I don't understand why. Documentation specifies that All folders output should contain all the subfolders. I'm asking because I found a bug in one of my programs caused by this unexpected behavior.
03-04-2016 05:37 AM
It isn't documented, so perhaps you could get a CAR from NI to update the documentation - but looking at the code for the VI it starts by adding the current folder to an array containing 'all folders'.
I couldn't explain the reasoning behind why it was done that way (you'd have to ask the guy who wrote it), but I think I can understand why it was done that way - I think it would look a bit weird if it returned files that were in the top level directory without returning the folder that contains them.
For example the output would be:
C:\LabVIEW Working Directory\Testing <----- top level folder
C:\LabVIEW Working Directory\Testing\Level Sensor.zip
C:\LabVIEW Working Directory\Testing\Level Sensor
C:\LabVIEW Working Directory\Testing\Level Sensor\Acquire Level Sensor Data.vi
etc.
I think this makes more sense than:
C:\LabVIEW Working Directory\Testing\Level Sensor.zip
C:\LabVIEW Working Directory\Testing\Level Sensor
C:\LabVIEW Working Directory\Testing\Level Sensor\Acquire Level Sensor Data.vi
If you were displaying the file list in a tree control, you'd probably want the top level folder so that you can add the files within it as a child item.
03-04-2016 08:12 AM
I was surprised by your observation, as I've successfully coded a number of recursive "Directory Tree Walking" algorithms, but then I noticed I didn't use Recursive File List, but rather used List Folder, which returns All Files and All Folders within the current Folder. Put this inside a recursively-called Reentrant VI and you have a Directory Tree Walker.
Bob Schor