打包exe后,dir​函数无法读取exe内​部文件夹数据。

6 visualizzazioni (ultimi 30 giorni)
rohany
rohany il 17 Mag 2023
Risposto: saimme il 17 Mag 2023
编写GUI时,在OpeningFcn里写入一个dir语句,其中test是GUI同一目录下的一个文件夹,内部含有子文件夹,目的是要读取test内所有文件夹的名字,现发现,直接运行GUI程序时,dir函数可以正常读取数据,但是打包成exe后,确无法读取,寻求各位大神帮助!
function Database_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to Database (see VARARGIN)
% Choose default command line output for Database
handles.output = hObject;
File_name=dir('test'); %该函数打包exe无法读取数据
% % Update handles structure
guidata(hObject, handles);

Risposta accettata

saimme
saimme il 17 Mag 2023
dir 肯定无法读取 exe 文件里面的东西你可以把读取文件放到exe 相同目录进行读取,又或 把需要读取的数据 直接在代码里面定义。

Più risposte (0)

Categorie

Scopri di più su 编程 in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!