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

Réponses (1)

Sebastian Castro
Sebastian Castro le 14 Mai 2015

0 votes

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

Catégories

En savoir plus sur SimEvents dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by