How to ensure the file path information in Matlab uialert windows is not abbreviated?

Below is my code:
File_W = fullfile(Path, 'Output', ['Test_.xlsx']);
message = sprintf(['An Excel file named ', File_W, ' has been generated!']);
uialert(app.mainWindow,message,'success','Icon','success');
It is very important for the file path information to be displayed in my uialert window. Unfortunately, Matlab decides to abbreviate to something like Volumes/Folder/../Output/Test.xlsx.
Is there a way I can force Matlab to do the right thing?

3 commentaires

The message is consistent with the possibility that the Path ends with /..

Leon
Leon le 17 Juin 2025
Modifié(e) : Leon le 17 Juin 2025
You are right. That might be why. Do you know how to fix that?
Path=strrep(Path,'..',''); % remove ellipses from Path (irrespective of position)
However, they may be significant -- the result of
Volumes/Folder/../Output/Test.xlsx
and
Volumes/Folder/Output/Test.xlsx
aren't the same.
You need to go back to where Path was set to see where/why the ellipses are there to be able to get to the particular subdirectory/folder without the reference.

Connectez-vous pour commenter.

Réponses (1)

dpb
dpb le 16 Juin 2025
Déplacé(e) : Adam Danz le 16 Juin 2025
Which OS? It might be an OS charateristic given the particular abbreviation.
Locally on Windows, the sprintf fails with an attempt to interpret the backslash in the file name as special characer,
>> message = sprintf(['An Excel file named ', File_W, ' has been generated!']);
Warning: Escaped character '\U' is not valid. See 'doc sprintf' for supported special characters.
>>
but
>> Path=cd
Path =
'C:\Users\Dxxxx\Documents\MATLAB\Work'
>> message = ['An Excel file named ', File_W, ' has been generated!']
message =
'An Excel file named C:\Users\Duane\Documents\MATLAB\Work\Output\Test_.xlsx has been generated!'
>> uialert(hUIF,message,'success','Icon','success');
>>
displayed the whole string wrapped...(Win 10, R2022b)

Produits

Version

R2024b

Tags

Question posée :

le 16 Juin 2025

Commenté :

dpb
le 18 Juin 2025

Community Treasure Hunt

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

Start Hunting!

Translated by