Re: How to "Archive" a text file with multiple handles open

Tech-Archive recommends: Speed Up your PC by fixing your registry



Hello dwainew@xxxxxxxxx,

The design is a little flawed. My first question is.. do you own all the file handles? If so you may wish to create a single point of writing/reading which could then easily have the archive code added to it. I use a similar method for writing to multiple log locations.

While there are open file handles you can't "zero out" (erase the contents of) a file. The reason being that the other file streams are looking for data at a particular location.. if you erase the file.. these other streams have no way of knowing this and can not reset the location they are looking to read/write.

-Boo

Problem: I'd like to archive off the contents of a text file.
However, other processes may have the file open, so
MoveTo(newfilepath) can't be done, as far as I've found.

Start with a 5 MB MyLog.txt file that may be opened (reading and/or
writing) by several handles. The Final state I'm looking for is an
archive file MyLog_YYYYMMDDHHMMSS.txt with the 5 MB contents and the
original file zeroed out or with a line indicating the archive
operation.

I'm looking for a way to use CopyTo(NewFilePath) and then "zero out"
the original file....

problem is, I've found no real discussions regarding DELETING text in
a previously established file. How can you use a binarywriter or
similar class to REMOVE bytes or add null bytes. I end up with a file
of the original length.

you can't use the traditional FileInfo instantiation with the Truncate
parameter, as this causes an access violation.

Any ideas?



.



Relevant Pages

  • Re: document ext3 requirements
    ... They can't explicitly control erase, but writing to any block in a block group ... if you have a raid5/6 array writing one sector to a stripe results in you reading the pairity block for that stripe, reading the rest of the sectors for the block on that disk, recalculating the pairity information and writing the changed sectors out to both disks. ...
    (Linux-Kernel)
  • Re: Table cells
    ... Were you watching Sesame Street this morning? ... was Zero --- Sorry, as a single Mom with a three and a ... penumbra might just shed some light on the reality or lack thereof imbued ...
    (alt.html)
  • Re: Problem writing to directly flash while IPSM running
    ... We are using the Intel Strata Flash 28F640J3A120 chips. ... Reading of the specification would seem to indicate that if an erase ... Similarly, when writing the program. ... Following on from that - how do I disable interrupts from the device ...
    (microsoft.public.windowsce.platbuilder)
  • Help: SuSE 8.2 pro CD writing problems.
    ... user could only see the dvd-rom in the k3b config. ... on /dev/sr1 to 660 to enable group disk to write to the emulated scsi ... Logged in as a normal, completely local user, I can erase a re-writable, ... re-gain acess to them (for writing). ...
    (alt.os.linux.suse)
  • Re: mmap() vs. O_DIRECT
    ... Does ftruncate only change the ... Or does it also zero the remaining part ... | before writing the last partial block. ... block internally instead of an internal buffer cache page. ...
    (comp.os.linux.development.system)