Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

What code opens folders on my computer

1 vue (au cours des 30 derniers jours)
Rainaire Hansford
Rainaire Hansford le 5 Juil 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
Is there a way to open a folder using MATLAB I am working on a talking program where I ask it to look for a file in my folder.
so far I have:
command=input('Located file');
if strcmpi(command,'Located file')
NET.addAssembly('System.Speech');
obj = System.Speech.Synthesis.SpeechSynthesizer;
obj.Volume = 100;
Speak(obj, 'Here it is');
end
And I would want it to open the folder.

Réponses (1)

Walter Roberson
Walter Roberson le 22 Juil 2018
Open the folder in what sense?
If you had the name of a directory and you were using MS Windows, then you could probably use
winopen(VariableThatContainsDirectoryName);
On Mac you could use something like,
system( sprintf('open "%s"', VariableThatContainsDirectoryName) );
Or perhaps you would prefer
cd(VariableThatContainsDirectoryName);
folderbrowser
  2 commentaires
Rainaire Hansford
Rainaire Hansford le 4 Août 2018
Right something like that and also to search for a file via file name. Where the code tell you its directory as well.
Could you show me example?
Walter Roberson
Walter Roberson le 5 Août 2018
[filename, filepath] = uigetfile('*.*', 'Pick a file');
if ~ischar(filename); return; end %user canceled
fullname = fullfile(filepath, filename);
winopen(fullname)
That would rely upon MS Windows to open it with the default program for that type of file.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by