Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree Control File and Folder Explorer with System Icons

Summary:

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 Code:

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.

ExplorerTree Recursive Files.png

The Display:

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.

ExplorerTree Recursive Files Tree.png

The Application:

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.

ExplorerTreeExample.png

Questions or Comments... Bring them on!

Files:

- 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)

Comments
jpao1990
Member
Member
on

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,

rcpacini
Member
Member
on

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.

pretech
Member
Member
on

Any chance of adding a version for labview 2011 please?

FernandoL
Member
Member
on

Thanks, excellent VI!

Best Regards.
Ing. Edgar Lojan
BertMcMahan
Active Participant
Active Participant
on

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:Remove self and parent folders_BD.png

 

Simply place this after the first "List folder" in "ExplorerTree Recursive Files.vi" and it'll work.

Contributors