Re: vb application locks file



On 7 Sep 2006 04:23:40 -0700, "davidwellan" <d.wellan@xxxxxxxxxx>
wrote:

I have resolved the 'input past end of file' error, thanks for the help
on that one. I basically did as you (Randy Birch) suggested and checked
that the file had something to read before reading it!!!

This has strangely reduced the crashing to a minimum, yet this error
occurred very infrequently (according to my log file) and wasn't always
the culprit of the app.'s failure.

I would still like to know if there is a way to force a specific file
to close?

We are about to re-write the system and I will use a copied file
solution and see if this will be more robust. We are also going to run
it on a new PC - this may have been the cause all along!

Do NOT use a copied file system

Make a temp file, close it and Rename it

A copied file turns up in the file system with a zero or non-zero
length (if an old one existed) long before it is ready to be read.

The rule is
1- reader deletes file
2- writer creates temp file
3- writer renames to real file
4- reader suddenly sees pristine file in readable state

One can fiddle with 1) - renaming is Ok



.



Relevant Pages

  • Re: Modifying a file w/o creating a temp file
    ... Of course there's one simple and obvious solution which has not yet been mentioned or rejected: read the whole file into memory, modify it there, truncate the original file, and write the modified data into it. ... This has substantial subtle benefits, balanced against the one flaw of being memory hungry and limited by swap space. ... Benefits include ease of use, if the original file had hard links to it, they are not broken, if it had special modes/attributes/ACLs, they are not lost, and it never needs more space than the file system has, whereas a temp-file solution typically needs an amount of unused disk space equal to the size of the temp file. ...
    (comp.lang.java.programmer)
  • Re: Modifying a file w/o creating a temp file
    ... ease of use, if the original file had hard links to it, they are ... space equal to the size of the temp file (unless the temp file is ... written to a different file system which raises its own issues). ... lost the file entirely. ...
    (comp.lang.java.programmer)
  • Re: Chkdsk problem
    ... > The type of the file system is NTFS. ... > Cannot lock current drive. ... > Chkdsk cannot run because the volume is in use by another ... liable for problems or mishaps that occur from the reader using advice ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Chkdsk problem
    ... >> The type of the file system is NTFS. ... >> Chkdsk cannot run because the volume is in use by ... >Have you installed SP2 yet? ... >The reader should exercise normal caution and backup the ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Ridiculous readInt() bug? Read-head not advancing far enough?
    ... Do you share the reference to the reader? ... Does it happen only if you read the file from the particular file system? ... Does it happen with different hard drives, or only with one particular drive? ... You best bet would be to manage to create a stand-alone test case which reproduces the bug, at least most of the time, in an acceptable time frame. ...
    (comp.lang.java.programmer)