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

Respuestas (1)

Sebastian Castro
Sebastian Castro el 14 de Mayo de 2015

0 votos

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

Categorías

Más información sobre Search Path en Centro de ayuda y File Exchange.

Preguntada:

el 14 de Mayo de 2015

Respondida:

el 14 de Mayo de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by