Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Erase a specified file of PC

Subject: Erase a specified file of PC

From: Sprinceana

Date: 31 Mar, 2009 18:35:03

Message: 1 of 5

How to delete a file in matlab when using uigetfile for selecting a file?


So I have a button I select my file using uigetfile function .

The thing I don't know is when I press on open button of the open dialog for selecting my file; so when I press open button of this open dialog(uigetfile) it deletes automatically a file from my computer.

Any ideas of what function I need to use?

Please a little example or help name_function in command window.

Thanks a lot,

Michael

Subject: Erase a specified file of PC

From: Eric W

Date: 31 Mar, 2009 19:38:01

Message: 2 of 5

"Sprinceana " <mihaispr@yahoo.com> wrote in message <gqtnon$752$1@fred.mathworks.com>...
> How to delete a file in matlab when using uigetfile for selecting a file?
>
>
> So I have a button I select my file using uigetfile function .
>
> The thing I don't know is when I press on open button of the open dialog for selecting my file; so when I press open button of this open dialog(uigetfile) it deletes automatically a file from my computer.
>
> Any ideas of what function I need to use?
>
> Please a little example or help name_function in command window.
>
> Thanks a lot,
>
> Michael

doc delete

Subject: Erase a specified file of PC

From: Sprinceana

Date: 31 Mar, 2009 19:47:01

Message: 3 of 5


> doc delete

Thank you!


I try to do this: (to delete from desktop folder for example photo.jpg after selecting it)

I pressed open and I hoped to be deleted from desktop(my file poza.jpg)

function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname] = uigetfile({'*.jpg';'*.png';'*.bmp'}); %selection du fichier en utilisant open dialog

if ~ischar(filename) %en tapant cancel il affiche une message d'erreur
    errordlg('Eroare!','Nici un fisier selectat!'); %erreur dialogue quand on presse sur cancel
   return;
 end


img = delete(fullfile(pathname,filename)); %after I select my file and push open delete my file from my pc automatically


What I have wrong in my pushbutton1_callback?

Any suggestion will be appreciated!

Subject: Erase a specified file of PC

From: Sprinceana

Date: 31 Mar, 2009 20:04:01

Message: 4 of 5

"Eric W" <gmail@ewilliams2006.com> wrote in message <gqtrep$49h$1@fred.mathworks.com>...
> "Sprinceana " <mihaispr@yahoo.com> wrote in message <gqtnon$752$1@fred.mathworks.com>...
> > How to delete a file in matlab when using uigetfile for selecting a file?
> >
> >
> > So I have a button I select my file using uigetfile function .
> >
> > The thing I don't know is when I press on open button of the open dialog for selecting my file; so when I press open button of this open dialog(uigetfile) it deletes automatically a file from my computer.
> >
> > Any ideas of what function I need to use?
> >
> > Please a little example or help name_function in command window.
> >
> > Thanks a lot,
> >
> > Michael
>
> doc delete

In command window delete xz.txt using command delete:

>>delete('C:\xz.txt')

And xz.txt was saved on C:\

How to modify my gui of pushbutton to automatically delete what I select using uigetfile method?

Subject: Erase a specified file of PC

From: Sprinceana

Date: 31 Mar, 2009 20:08:01

Message: 5 of 5

"Sprinceana " <mihaispr@yahoo.com> wrote in message <gqtsvh$cc8$1@fred.mathworks.com>...
> "Eric W" <gmail@ewilliams2006.com> wrote in message <gqtrep$49h$1@fred.mathworks.com>...
> > "Sprinceana " <mihaispr@yahoo.com> wrote in message <gqtnon$752$1@fred.mathworks.com>...
> > > How to delete a file in matlab when using uigetfile for selecting a file?
> > >
> > >
> > > So I have a button I select my file using uigetfile function .
> > >
> > > The thing I don't know is when I press on open button of the open dialog for selecting my file; so when I press open button of this open dialog(uigetfile) it deletes automatically a file from my computer.
> > >
> > > Any ideas of what function I need to use?
> > >
> > > Please a little example or help name_function in command window.
> > >
> > > Thanks a lot,


I used now function delete also in my GUI and works perfectly for removing a file selected!

> > >
> > > Michael
> >
> > doc delete
>
> In command window delete xz.txt using command delete:
>
> >>delete('C:\xz.txt')
>
> And xz.txt was saved on C:\
>
> How to modify my gui of pushbutton to automatically delete what I select using uigetfile method?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us