Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

_close() for file handle issue in windows

Posted on 2004-10-04
3
Medium Priority
?
292 Views
Last Modified: 2012-05-05
Hi all,

  Im opening a binary file and reading block by block of data from it using _open() and _read() and closing the file with _close(). For reading each record im opening and closing the file.Iam reading the file in binary read mode.

After i process all the records i need to move the file to a different folder. Which im unable to do. The error is sharing voilation. I made sure that all the file handles are closed. Even then im not able to move the file instead im able to copy the file. But my requirement is i need to move this file.

This problem is not occuring for each and every file. this is only occuring at times. Is this anything to do with Os not releasing the file handle.

I also tried it by putting a sleep of 1second between the binary file reading and moving the file. Did any body face this issue and can anyone tell me a solution.

Thanks in advance

Vidya
0
Comment
Question by:vidyavardhan
3 Comments
 

Author Comment

by:vidyavardhan
ID: 12274003
I have found the solution for myself the file i was trying to copy was being opened and accessed for 50 times before i copy it. So OS in this sittuation is taking 500 milliseconds to release the file handle.

Thus the problem is fixed.

Thank you
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12502626
PAQed, with points refunded (50)

modulo
Community Support Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Six Sigma Control Plans
Loops Section Overview

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question