Use PictureBox.Image or DrawImage?

  • Thread starter Thread starter Just Me
  • Start date Start date
J

Just Me

I do the following where sss is a string equal to a filename.

PictureBox.Image = = New Bitmap(sss)

It occurred to me that the file will be locked until the picturebox is
disposed at the program end.

Would it make more sense to use DrawImage.

I mean, is that what programmers typically do?



Thanks
 
Hi,

If you open the bitmap with a filestream you won't lock the file.

Dim fs As New System.IO.FileStream("C:\camera.bmp",
IO.FileMode.Open)
Dim bm As New Bitmap(fs)

fs.Close()
PictureBox1.Image = bm


Ken
---------------
 
Perfect - thanks a lot

Ken Tucker said:
Hi,

If you open the bitmap with a filestream you won't lock the file.

Dim fs As New System.IO.FileStream("C:\camera.bmp",
IO.FileMode.Open)
Dim bm As New Bitmap(fs)

fs.Close()
PictureBox1.Image = bm


Ken
 
Back
Top