Tuesday, June 19, 2007

Image.FromFile locks the file

When you use the picturebox to display pictures and fill it by using

Picturebox1.Image = Image.FromFile("somefile"),

You will find that it locks the image file.

There are 2 solutions,

The first is to dispose of the image :

Picturebox1.Image.Dispose()

Wich is ok when you are going to put another picture in the picturebox but can lead to surprising results in other cases.

The second (and advised way) is to use a file stream :

Dim fs As System.IO.FileStream

fs = New System.IO.FileStream("somefile", IO.FileMode.Open, IO.FileAccess.Read)

PictureBox1.Image = System.Drawing.Image.FromStream(fs)

fs.Close()

Wednesday, June 13, 2007

Tuesday, June 5, 2007

Missing CD/DVD rom drives in Windows?

Trying to write a cd,
I noticed my DVD writer was missing,

Looking in device manager i got the following error message :

Windows cannot load the device driver for this hardware. The driver may be corrupted or missing. (Code 39)

very strange, as this device has always worked perfectly before.

After some googleing I tried things to update the drivers, deleting the device from device manager etc.

Finally i found the answer :

Open regedit
Go to key :

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E965-E325-11CE-BFC1-08002BE10318}

Find the "UpperFilters" and "LowerFilters" (and "UpperFilters.bak" "LowerFilters.bak", if they exist) values and delete them.


After that reboot or delete the devices one more time from device manager and voila they were back!

WARNING : some CD / DVD writer programs may have to be reinstalled!!! but that's a small price to pay i find :)