By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

file locked after closing...

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.