File locking issue in mscorlib.dll

G

Guest

After accessing an image file in my VB.Net application, then disposing of the
form which accessed the file and loading another form in the same app, I'm
attempting to copy said image file into an instance of the XPBurn component.
This is throwing an exception with the following text:

An unhandled exception of type 'System.IO.IOException' occurred in
mscorlib.dll

Additional information: The process cannot access the file
"Z:\Nurses_Project\db2\Records\00000002_10_12_2004\Images\DSC_0003.JPG"
because it is being used by another process.

Does anyone know a way of "unlocking" this file without completely shutting
down the application? ( file.unlock(filename) does not work in this case)
 
N

Norman Yuan

I would go back to examine the mehtod/procedure where the image file is
accessed the first time. How is the file acccessed? Say, you open Stream on
the file, read the image into a byte array from the Stream, then you should
CLOSE the Stream properly. That is, if you open a file (or other type of
resources) you are supposed to close it. Do not leave it open and jump to
other processs and attempt from there to "unlock" the file you previously
opened.
 
J

Jochen Kalmbach

Hi=?Utf-8?B?RHIgUQ==?=,
After accessing an image file in my VB.Net application, then disposing
of the form which accessed the file and loading another form in the
same app, I'm attempting to copy said image file into an instance of
the XPBurn component. This is throwing an exception with the following
text:

You forgot to close the file!


--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
G

Guest

In the procedure where the file is opened, I am loading the image into a
picturebox using:

PictureBox.Image = Image.FromFile(filename)

I will play around with this some more...

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top