How to prevent user from changing directory using uiputfile
显示 更早的评论
I would like to allow a user to select a name for a file to be saved using a standard dialog box for saving files, such as uiputfile, but I do not want the user to have the freedom to choose the folder (directory). Is there a way to do this using uiputfile or is there some alternative you can suggest. Note that other parts of my application are depending upon having all of the files saved in the same folder (which I designate) so I can't allow the user to save files into an arbitrary folder. Thanks for your assistance
采纳的回答
更多回答(2 个)
Azzi Abdelmalek
2014-1-30
folder='E:\matlab';
fol='';
while ~isequal(folder,fol)
[fil,fol]=uigetfile(folder,message)
end
Azzi Abdelmalek
2014-1-30
You can use Listdlg function
folder='E:\matlab';
d=dir([folder '\*.m']);
f={d.name};
a=listdlg('PromptString','Select a file:','ListString',f)
file=f(a)
3 个评论
Jon
2014-1-30
Azzi Abdelmalek
2014-1-30
a=listdlg('PromptString','Select a file:','SelectionMode','single','ListString',f)
What other functionality do you need?
Jon
2014-1-30
类别
在 帮助中心 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!