How do I create an App Designer App that lists the contents of a user-chosen directory?

133 views (last 30 days)
I would like to design an app that allows the user to browse for a folder, that displays the folder location, and that displays the folder contents to the app.  I would like to use App Designer to make the app.  How can I do this in App Designer?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Oct 2021
Edited: MathWorks Support Team on 26 Oct 2021
Refer to the attached example App Designer file named 'ExampleDirectoryApp.mlapp'.  In the attached example App, there is a 'browse' button, a label to display the selected folder location, and a uitable to display the contents of the selected folder location.  When the app is run, the user clicks on the 'browse' button to trigger a callback.  The callback executes the 'uigetdir' command to get the directory and then displays the directory to the label.  Finally, the callback obtains the directory contents using the 'dir' command and displays the contents in the uitable.
 
For more information and details about the implementation, refer to the attached file and the comments in the file.  Please note that, because the contents of the directory are displayed in a uitable, the contents are selectable.  That is, if desired, the 'CellSelectionCallback' can be created on the uitable to execute code based on the user's selection of the folder's contents.  Please also note that the app was designed to be run in MATLAB R2018a.
 
For more information about the relevant functions and callbacks in this example app, please refer to the following links:
 
NB
: If you are having trouble downloading the attachment, please right-click on the file and select 'Save link as...'.
  3 Comments

Sign in to comment.

More Answers (2)


John Cunningham
John Cunningham on 27 Aug 2021
See if this works, this is more what I was looking for. The directory structure opens as a tree, and you can execute whatever you need to on the selected file. Thanks to the original example authors for pointing me in the right direction. Written using 2019b.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!