Delete a file on click of Pushbutton
Show older comments
Hi all !!!!
I have created a GUI(fig). It has one editbox and one pushbutton on it.
I have some dat files like (1.dat, 2.dat, 3.dat etc.).
I want to delete the dat file which is entered in that editbox(like 1,2,3 etc...).
I have written the following code for pushbutton_callback :
delID=get(handles.editDel,’String’);
delete(‘delId.dat’);
but when I click pushbutton, nothing happens….
Please Help ….
Thank You….
Answers (1)
Jiro Doke
on 27 Mar 2011
Try:
delete([delID, '.dat'])
Explanation: delID is a variable that contains character string. To construct the file name, you need to concatenate the variable with '.dat'. When you specify 'del1ID.dat', you're looking for a file called 'del1ID.dat', which you obviously don't have.
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!