How do I write a script for a GUI.m file that allows me to press a button, choose a (*.csv) file and then copy this (*.csv) file to the current folder so it can be used for an existing simulation?
이전 댓글 표시
I already have a pushbutton that when pressed allows me to browse for a (*.csv) file. I tried the copyfile function as follows but get an error:
[filename, pathname, filerindex] = uigetfile('*.csv');
[success,message,messaageid] = copyfile(pathname,'A:\',filename);
A:\ is a mapped network drive.
I get the following error: Error using copyfile 'Data1.csv' is an invalid option string.
My code for the pushbutton in the GUI.m file is:
% --- Executes on button press in cmd_getDir.
function cmd_getDir_Callback(hObject, eventdata, handles)%****BROWSE button
[filename, pathname, filerindex] = uigetfile('*.csv'); %Get file
[success,message,messaageid] = copyfile('pathname','A:\',filename);%Need to copy file to current folder
assignin('base','FileCSV',filename); %assign the name FileCSV to the file
set(handles.text_directory,'String', filename); %Put filename in string space
% hObject handle to cmd_getDir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
I understand from the MATLAB help that:
[SUCCESS,MESSAGE,MESSAGEID] = copyfile(SOURCE,DESTINATION,'f') attempts to copy SOURCE to DESTINATION, as above, even if DESTINATION is read-only. The status of the writable attribute of DESTINATION will be preserved.
INPUT PARAMETERS:
SOURCE: 1 x n string, defining the source file or directory.
DESTINATION: 1 x n string, defining destination file or directory. The default is the current directory.
MODE: character scalar defining copy mode.
'f' : force SOURCE to be written to DESTINATION. If omitted, copyfile respects the current writable status of DESTINATION.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!