473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2256
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ted Duross | last post by:
Hi, I’ve created an educational software application accessed by students from a central server. On Start-Up the application reads an XML file that stores student progress records. This XML...
1
by: MFRASER | last post by:
I am trying to create a simple log file function that logs the timespan and a message. Problem with my code is that I get an error that the file is being access by another process. What am I...
3
by: Sagaert Johan | last post by:
I have a program that uses the filesystemwatcher. Problem is that i have to wait until the file is closed before i can do someting with it in the changed event. How can i detect if the...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
3
by: Ron Vecchi | last post by:
I have a single line file where the line will be read and updated each time it is opened. My question is I need to open it with a lock so noone else can read or write to it untill the lock is...
2
by: C | last post by:
Hi, I have a web app whereby I extract some data from an Excel Sheet. Once I have extracted my data I close my Excel Object. I then try to delete the file. When I try to delete the file...
2
by: Sagaert Johan | last post by:
Hi I have a problem with an mdb file still being locked after i closed the OleDBConnection. (can't rename or delete the file) Is there anything that still has some open filehandle to the mdb ?...
1
by: ABCL | last post by:
Hi All, I am working on the situation where 2 different Process/Application(.net) tries to open file at the same time....Or one process is updating the file and another process tries to access...
5
by: cmay | last post by:
The only examples I have seen on how to check if a file is locked is to try to open it a catch an exception. MS has stated that you should never use error trapping in this manner. Is there no...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.