Hi Mike,
I tried your suggestion but the file was still locked. However, I
solved it using:
picbox.Image.Dispose()
before attempting to move the file.
Thanks
Michael D. Ober wrote:
> This appears to be a bug in the Windows API itself. The workaround is to
> create a dummy tif image and load it into the picbox before attempting to
> move the original image. I have the same problem in one of my older
> programs that uses the Kodak Image OCX drivers.
>
> Mike Ober
>
> "yoav" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi Folks,
> >
> > The following code crashes on the last statement with a "The process
> > cannot access the file because it is being used by another process"
> > exception (fiFax is a FileInfo object):
> >
> > Dim picbox As New PictureBox
> > picbox.Image = Drawing.Image.FromFile(fiFax.FullName)
> > picbox.Dispose()
>
> picbox.Image = new Drawing.Image
>
> or
>
> picbox.Image = Drawing.Image.FromFile("dummy.tif")
>
> > fiFax.MoveTo(fiFax.Directory.FullName & "\Old\" &
> > fiFax.Name) ' Exception!!!
> >
> > If I put the "fiFax.MoveTo" statement before the "FromFile" it works.
> > Why does the picturebox keeps the file locked even after it is
> > disposed? How can I release it?
> >
> > TIA
> >
> >
|