File delete

  • Thread starter Thread starter JoskeXP
  • Start date Start date
J

JoskeXP

Hi,

When I use the following code I have a error that the file is in use

If File.Exists("c:\RegistratieMD\images\" + Me.txtBarcode.Text + ".jpg")
= True Then
File.Delete("c:\RegistratieMD\images\" + Me.txtBarcode.Text+ ".jpg")
End If

How can I solve this problem

Thx

JoskeXP
 
Basically you can't.. if the file is in use you won't be able to delete it
until it gets closed.
 
Basically you can't.. if the file is in use you won't be able to
delete it until it gets closed.

HI,

I used the file before for filling a picture box with this code

imgFotoOK.Image = Image.FromFile("c:\RegistratieMD\images\" +
Me.txtBarcode.Text + ".jpg")

and now I have to delete this file and make a new file (with the same name)
with another picture.

How can I do this than.

Thx

JoskeXP
 
* JoskeXP said:
I used the file before for filling a picture box with this code

imgFotoOK.Image = Image.FromFile("c:\RegistratieMD\images\" +
Me.txtBarcode.Text + ".jpg")

and now I have to delete this file and make a new file (with the same name)
with another picture.

Create a new 'Bitmap' object, draw the original bitmap into the new
bitmap, then dispose the original 'Bitmap' object by calling its
'Dispose' method and assign the new bitmap to the control's 'Image'
property.
 
Hi,

Open the bitmap with a filestream.

Dim fs As New System.IO.FileStream("C:\deleteme.bmp",
IO.FileMode.Open)
Dim bm As New Bitmap(fs)
fs.Close()
picturebox1.image = bm
System.IO.File.Delete("C:\deleteme.bmp")

Ken
----------------
 
Hi,

Open the bitmap with a filestream.

Dim fs As New System.IO.FileStream("C:\deleteme.bmp",
IO.FileMode.Open)
Dim bm As New Bitmap(fs)
fs.Close()
picturebox1.image = bm
System.IO.File.Delete("C:\deleteme.bmp")

Ken

Hi,

works perfect

Thanks

JoskeXP
 
Back
Top