Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

What code opens folders on my computer

조회 수: 2 (최근 30일)
Rainaire Hansford
Rainaire Hansford 2018년 7월 5일
마감: MATLAB Answer Bot 2021년 8월 20일
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.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 7월 22일
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
Rainaire Hansford
Rainaire Hansford 2018년 8월 4일
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 2018년 8월 5일
[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.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by