How to check for file existence in previous folder
29 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Allan Paolo
le 4 Oct 2021
Réponse apportée : Image Analyst
le 4 Oct 2021
Hi.
I am fully aware of "exist" to check if a file exists in the same directory: ie. exist('kvals.mat', 'file') == 2 checks if kvals.mat exists in the same directory.
How do I do this if I want to check the existence of kvals.mat in the previous directory?
0 commentaires
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 4 Oct 2021
Construct the filename in the other/previous folder, and the use isfile() to see if it exists
otherFullFileName = fullfile(otherFolder, 'kvals.mat')
if isfile(otherFullFileName)
% File exists.
else
% File does not exist.
end
0 commentaires
Voir également
Catégories
En savoir plus sur File Operations 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!