GUI - Populating listbox with File List

1 view (last 30 days)
onamaewa
onamaewa on 17 Oct 2019
Commented: Adam on 17 Oct 2019
I have inseted a Click and List Box in GUI.
Procedurally, I would like to click the Click Box to open the computer's File Directory, select a file, and have its contents populate the Listbox.
Reading the documentation, I've tried implementing lbox2 and lbox1 but haven't been successful.
How can I achieve this?
  1 Comment
Adam
Adam on 17 Oct 2019
doc uigetdir
will let you search for a directory
doc dir
will let you manipulate the information content of a directory, such as the listing of files and filter out stuff you don't want (e.g. '.' and '..' or all subfolders etc).
If you want to read the contents of a file then there are various ways to do that depending what type of file it is, but once you have it all in a string or cell array of strings/chars you can just assign it to the 'String' property of your listbox.

Sign in to comment.

Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!