matlab GUI 实现文件夹选择

matlab实现多个文件夹选择
function [pathname] = uigetdir2(start_path, dialog_title)
% Pick multiple directories and/or files

import javax.swing.JFileChooser;

if nargin == 0 || start_path == '' || start_path == 0 % Allow a null argument.
    start_path = pwd;
end

jchooser = javaObjectEDT('javax.swing.JFileChooser', start_path);

jchooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
if nargin > 1
    jchooser.setDialogTitle(dialog_title);
end

jchooser.setMultiSelectionEnabled(true);

status = jchooser.showOpenDialog([]);

if status == JFileChooser.APPROVE_OPTION
    jFile = jchooser.getSelectedFiles();
	pathname{size(jFile, 1)}=[];
    for i=1:size(jFile, 1)
		pathname{i} = char(jFile(i).getAbsolutePath);
	end
	
elseif status == JFileChooser.CANCEL_OPTION
    pathname = [];
else
    error('Error occured while picking file.');
end


单个文件夹选择
Open folder selection dialog box
使用

uigetdir

folder_name = uigetdir
folder_name = uigetdir(start_path)
folder_name = uigetdir(start_path,dialog_title)


Description

folder_name = uigetdir displaysa modal dialog box showing the folders that are inside the currentworking directory. This dialog allows you to navigate to a folderand select it (or type the name of a folder). If the folder you specifyexists, uigetdir returns the selected path whenyou click OK. If you click Cancel (orthe window's close box), uigetdir returns 0.

folder_name = uigetdir(start_path) showsthe folders that are inside the folder, start_path.If start_path is an empty string ('')or is not a valid path, the dialog box opens in the current workingdirectory.

folder_name = uigetdir(start_path,dialog_title) opensa dialog box with the title, dialog_title. Thedefault dialog_title is Select Directoryto Open.

Note:  The visual characteristics of the dialog box depend on the operatingsystem that runs your code. For instance, some operating systems donot show title bars on dialog boxes. If you pass a dialog box titleto the uigetdir function, those operating systems will not displaythe title.


 


获取文件

uigetfile

保存文件

uiputfile

保存变量到文件

uisave

Open dialog box for saving variables to MAT-file



  • 7
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ls1300005

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值