File access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a bit of a problem. I need to determine if a file is in use, to know
whether or not I can overwrite it. At first I tried calling the
GetModuleHandleA function, but that always returns that the file is free. I
then tried to open the file with a file stream, if an error occurred the file
was in use. My problem with that, is there is no consistency. I can test it
10 times, and get 50/50 results, when I know the file is currently being
accessed. I'm not sure what else to try.

Any suggestions would be appreciated.

Thanks in advance,
Jeff
 
When you tried to open the file using a stream , did you specify an
exclusive lock on the file? That should have worked.
 
I did specify a lock. I tried all of the open methods, with all of the
locks, and it was either always in use, or not in use. I could not get
results that were consistantly accurate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top