How to "Archive" a text file with multiple handles open
- From: dwainew@xxxxxxxxx
- Date: 16 Jun 2006 10:06:16 -0700
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?
.
- Follow-Ups:
- Re: How to "Archive" a text file with multiple handles open
- From: GhostInAK
- Re: How to "Archive" a text file with multiple handles open
- Prev by Date: How do I get newly edited info back in datagridview after save is made
- Next by Date: Re: Assigning Nullables to each other
- Previous by thread: How do I get newly edited info back in datagridview after save is made
- Next by thread: Re: How to "Archive" a text file with multiple handles open
- Index(es):
Relevant Pages
|