Delete a file on click of Pushbutton

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….

Réponses (1)

Jiro Doke
Jiro Doke le 27 Mar 2011

0 votes

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.

Catégories

En savoir plus sur Simulink dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by