Solved

_close() for file handle issue in windows

Posted on 2004-10-04
3
239 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now