You might want to use a BufferedStream (for reading & writing)
when the log file is going to be to large to fit into memory.
The idea is to always write to another file, and rename it afterwards.

using ( FileStream readFs ...)
using ( BufferedStream readBuf( readFS))
using ( FileStream writeFs ...)
using ( BufferedStream writeBuf( writeFS))
{
  // write first contents through writeBuf
  ...

  // now just copy the bytes
  int b = readBuf.ReadByte();
  while ( b != -1)
  {
    writeBuf.WriteByte( b);
    b = readBuf.ReadByte();
  }
}

// delete old file
// rename new file

HTH
// Ryan

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to