How to delete the File

A

Amit D.Shinde

I have Filelistbox(VB6 control on my form).
IT contains .jpg, .bmp files. The selected file in list box is
displayed in picturebox control.
If I want to allow the user to delete or rename this file.
For deleting the file I am usin the Kill function.

But it gives me error that File is in Use.
What is the other way to do this.
Please Help Me
Amit D. Shinde.
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (Amit D.Shinde) scripsit:
I have Filelistbox(VB6 control on my form).
IT contains .jpg, .bmp files. The selected file in list box is
displayed in picturebox control.
If I want to allow the user to delete or rename this file.
For deleting the file I am usin the Kill function.

But it gives me error that File is in Use.
What is the other way to do this.

I assume you are loading the file using 'Image.FromFile'. Use this code
instead (this will avoid locking the file):

\\\
Dim fs As FileStream = New FileStream("C:\WINDOWS\Angler.bmp", FileMode.Open)
Dim bmp As Bitmap = New Bitmap(fs)
fs.Close()
///
 
A

Amit D.Shinde

* (e-mail address removed) (Amit D.Shinde) scripsit:

I assume you are loading the file using 'Image.FromFile'. Use this code
instead (this will avoid locking the file):

\\\
Dim fs As FileStream = New FileStream("C:\WINDOWS\Angler.bmp", FileMode.Open)
Dim bmp As Bitmap = New Bitmap(fs)
fs.Close()
///

Kill function permenantly deletes the file but i want it to send it to
recycle bin..how should i do it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top