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

6 Ansichten (letzte 30 Tage)
rohany
rohany am 17 Mai 2023
Beantwortet: saimme am 17 Mai 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);

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu 编程 finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!