Removing blocks of text

  • Thread starter Thread starter Robert Scheer
  • Start date Start date
R

Robert Scheer

Hi.

My application uses a text file as a log. Each log entry has six lines
of text representing data about the application. I need to keep the
file size reasonable so I am trying to write a routine that removes
older entries. My problem is that I could not solve how to remove one
entire block of six lines, once my routine detects it is a older
entry.

That's an example of my log:

--------------------------
Date : 09/09/2004 09:18:30
Module : DataAccess
User : Jim
Sector : RZ
--------------------------

Can anyone help me on this issue?

Thanks,
Robert Scheer
 
Robert,

Do you want to open and close the file for a while and rebuild it or do you
want that while the file keeps open for logging.

When it is the last you can forget it, there is a open new, and an append
however not a cut from the middle.

When you can open and close the file, than it is just reading and putting
the 6 rows in a little array when "-----" until "------" occurs. And than
writing that array when the date is false and going on when the date is
true.

I hope this helps?

Cor
 
how about using XML files for logging? They are well structured and hence
should be easier to manipulate anyway you want - especially since .NET has
pretty good support for XML.

Imran.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top