how use uigetfile to get file or new file
12 次查看(过去 30 天)
显示 更早的评论
采纳的回答
dpb
2023-6-18
移动:dpb
2023-6-18
Well, there is no file of that name in the displayed directory; uigetfile does not return a file that does not already exist; that's just the nature of the beast.
To either select an existing file OR allow the user to create a new file, use uiputfile instead; it has the same appearance but will return the new user-supplied file name if given rather than a selected name.
The other difference is that if the user does select an existing name, then a warning dialog is displayed asking if the user wants to overwrite the existing file or not -- this can be disconcerting to a user so may need to be careful in the message one chooses there. Neither actually opens the file; all they do is return the file name/directory to the application for subsequent use however is chosen to do so. Hence, the file will not be overwritten or destroyed when selected in uiputifle despite the default message; that will depend upon what the app does afterwards.
There is no specific UI to give then browser interface to only enter a new file name; if that is the intent and the only acceptable action, then one could use uigetdir to let the user navigate to the desired folder and then follow that up by asking for the new file name in a dialog instead.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dialog Boxes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!