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

27 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
Jesus Sanchez
Jesus Sanchez on 12 Jul 2019
Nevermind, using uigetdir it is easy enough to not need further guidance.
Thanks for your time

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!