Is it possible to get the path of a file using uigetfile() ?
40 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hamlet López
le 23 Juin 2022
Modifié(e) : Hamlet López
le 23 Juin 2022
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]);
0 commentaires
Réponse acceptée
Walter Roberson
le 23 Juin 2022
[filename, filepath] = uigetfile();
if ~ischar(filename); return; end %user cancel
fullname = fullfile(filepath, filename);
fprintf('This is the file path: %s\n', fullname);
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Low-Level File I/O dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!