Is it possible to get the path of a file using uigetfile() ?

조회 수: 5 (최근 30일)
Hamlet López
Hamlet López 2022년 6월 23일
편집: Hamlet López 2022년 6월 23일
What I want to do is get the path of a file that user selects, lets say an image is in downloads folder (example: 'C:\Users\%UserName%\Downloads\image.png').
So when executing the script the path of file is saved in a string and showed in command window.
Right now I have no succes with the following, I'm I using the correct functions for this?
filepath = fileparts( uigetfile() );
disp(['This is the file path: ',filepath]);

채택된 답변

Walter Roberson
Walter Roberson 2022년 6월 23일
[filename, filepath] = uigetfile();
if ~ischar(filename); return; end %user cancel
fullname = fullfile(filepath, filename);
fprintf('This is the file path: %s\n', fullname);
  댓글 수: 1
Hamlet López
Hamlet López 2022년 6월 23일
편집: Hamlet López 2022년 6월 23일
OK, this is what I was looking for. Thank you very much Sir.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by