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

답변 (1개)

Jiro Doke
Jiro Doke 2011년 3월 27일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

질문:

2011년 3월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by