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?