469,575 Members | 1,206 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,575 developers. It's quick & easy.

file locked after closing...

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?
Sep 15 '07 #1
5 2046
buu wrote:
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?

--
Göran Andersson
_____
http://www.guffa.com
Sep 15 '07 #2
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?
"Göran Andersson" <gu***@guffa.comwrote in message
news:OA****************@TK2MSFTNGP05.phx.gbl...
buu wrote:
>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?

--
Göran Andersson
_____
http://www.guffa.com

Sep 15 '07 #3
buu wrote:
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?

--
Göran Andersson
_____
http://www.guffa.com
Sep 15 '07 #4
buu
using:

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

bitmap object does not have close statement
"Göran Andersson" <gu***@guffa.comwrote in message
news:O6****************@TK2MSFTNGP04.phx.gbl...
buu wrote:
>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?

--
Göran Andersson
_____
http://www.guffa.com

Sep 16 '07 #5
buu wrote:
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.

--
Göran Andersson
_____
http://www.guffa.com
Sep 16 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ted Duross | last post: by
1 post views Thread by MFRASER | last post: by
3 posts views Thread by Sagaert Johan | last post: by
3 posts views Thread by Ron Vecchi | last post: by
2 posts views Thread by C | last post: by
5 posts views Thread by cmay | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.