List of Files on a folder

Hi, I have been trying to make this... A dialog box where my input is a directory, once I entry a directory it shows a list of a files contained in the directory... I have tried in so many ways and nothing works :( thanks for advance

Answers (1)

To make a dialog box, you can use the uigetdlg function:
dirName = inputdlg('Enter value here:')
Then, whatever is returned by the dialog, you can use with the dir function. Notice I had to index into the results because of the way they are formatted:
dirInfo = dir(dirName{1})
That dirInfo variable will be a structure array that will, among other things, have a "name" field associated with it. So I can say:
dirInfo(6).name
ans =
downloads
Also, there is a function called uigetdir which lets you pick a folder using your operating system's file browser (e.g. Windows Explorer). Try this out, as maybe it is closer to what you need?
dirName = uigetdir
- Sebastian

Categories

Asked:

on 14 May 2015

Answered:

on 14 May 2015

Community Treasure Hunt

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

Start Hunting!