The documenation on System.Drawing.Bitmap.FromFile is incomplete as it does not mention what happens with file. However, see the documentation for System.Drawing.Bitmap(String):
http://msdn.microsoft.com/en-us/library/0cbhe98f.aspx[
^]
It says:
"The file remains locked until the Bitmap is disposed."
It's unclear from the documentation what kind of "lock" is taken on it. You'd assume it is opened for read, so that writes to the file are locked -- but it's not clear if shared reads are supported or locked out.
The trivial implementation of the constructor probably uses the FromFile method -- so it's plausible to assume the documentation that applies to the constructor also applies to FromFile.
Later, you try to open the file again using:
FileSteam(filename, FileMode.Open)
But you don't specify the access mode or shared acces mode, and it's again, not clear from the documentation what the default is.
What you probably want to do is explicitly open a file stream with shared read access and use that to create the bitmap:
Dim imgStream as FileStream new(imge, FileMode.Open, FileAccess.Read, FileShare.Read)
PictureBox1.Image = System.Drawing.Bitmap.FromStream(imgStream)
And then open it again the same way to access the data for storing in the database:
Dim fs As FileStream = New FileStream(mImageFilePath.ToString(),
FileMode.Open, FileAcess.Read, FileShare.Read)