file locked after closing...

B

buu

I have an app made in vb.net with a part of it made in vc.net.
after finishing a data processing with a file, I would like to delete that
file, but file remains locked

to be sure, I was:
- closing file (in part made in vc.net)
- closing object (vc)
- calling GC.Collect
- calling GC.WaitForPendingFinalizers

but, it's still the same.
what could be wrong?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

buu said:
I have an app made in vb.net with a part of it made in vc.net.
after finishing a data processing with a file, I would like to delete that
file, but file remains locked

to be sure, I was:
- closing file (in part made in vc.net)
- closing object (vc)
- calling GC.Collect
- calling GC.WaitForPendingFinalizers

but, it's still the same.
what could be wrong?

If you closed the file properly, that should be the only step needed.
The garbage collector has nothing to do with it after that.

The most likely reason, with the information given, is that you didn't
manage to close the file properly. Can you show the code where you close
the file? Have you determined that the code where you close the file
really is executed?
 
B

buu

I'm not an expert in c++, and a part that manages file is written in c.
there is only one statement:
myBitmap = nullptr;


and that's all.
what more should be done to close the file?
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

buu said:
I'm not an expert in c++, and a part that manages file is written in c.
there is only one statement:
myBitmap = nullptr;

and that's all.

That doesn't close any file.
what more should be done to close the file?

Well, how do you open the file?
 
B

buu

using:

myBitmap = (Bitmap^) Bitmap::FromFile(fileName);

bitmap object does not have close statement
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

buu said:
using:

myBitmap = (Bitmap^) Bitmap::FromFile(fileName);

bitmap object does not have close statement

I see. If you create the Bitmap object that way, the file is locked
until you call Dispose on the object.

Open a stream to read the file, create the bitmap from the stream, and
close the stream.
 

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