This example replicates a file explorer window including the default file icons in a LabVIEW Tree Control. Unlike the Recursive File List VI, this displays the sub-directories before the files regardless of alphabetical order. For non-LabVIEW file extensions, the system shell icons are returned. This means you won't need to maintain your own custom symbols for different file extensions.
The follow VI replaces the Recursive File List VI so the directories are sorted before the files. The files and folders are returned as a hierarchy path array. The folder indexes allow the developer to filter by folder or file type.
Listing content is easy, the next step is creating a professional looking display to view the files, no problem... This VI takes the path heirarchy and converts them to Tree items. In addition, glyphs are cached for each file extension to set the tree's custom symbols array which gives your tree that professional look.
Check out the example VI to see how this works. This is also supported at Run-Time which means you can build your own file explorer and customize the tree as you see fit.
Questions or Comments... Bring them on!
- ExplorerTree Example.vi - Top Level Example
- ExplorerTree Recursive Files.vi - Directory and alphabetically sorted recursive file list (the meat..)
- ExplorerTree Recursive Files Tree.vi - Folder content to Tree control items and glyphs (..and potatoes)
Thank for your post.
Do you know if its possible to get the rendered icon version of the file that windows uses on the Desktop.
Thanks,
I'm not sure i understand your question. The application's Get Shell Icon of File method returns the registered windows shell file symbol for the specific file. This depends on the application selected for the specific file type.
Any chance of adding a version for labview 2011 please?
Thanks, excellent VI!
Found a small bug: "List Folder" returns odd data for certain file names that start with certain characters. With these files, "List folder" adds "." and ".." to its outputs, meaning this function gets stuck and keeps looping indefinitely. See this thread:
https://lavag.org/topic/10982-list-folder-returns-incorrect-results-for-folders-on-network-drives/
I can't add attachments to this document but here's a snippet that the OP can use to create a subVI that he can add if he'd like:
Simply place this after the first "List folder" in "ExplorerTree Recursive Files.vi" and it'll work.