Delete line from text file

I'd like a DeleteLine function to create some type of 'rolling log'
i.e., log file gets to a certain size, then starts deleteing lines from the top so that new lines can be added.

How can i do this?
gwarguitarAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Ready1Connect With a Mentor Commented:
just a thought i use log4net to do all my logging in my application:

http://logging.apache.org/log4net/

it handles all the filesizes for you so you limit the size of your log file to eg. 100kb.. or it will auto rollover to a new file.

Regards,
Ready1
0
 
gwarguitarAuthor Commented:
umm... not seeing anything in there that helps me with my problem.
0
 
anarki_jimbelCommented:
Primitive approach would be as follows:

read the file to a string variable and count number of lines (while loop...).
If number of lines exceeds some limit, take substring starting from the first occasion of newline character to the end (may be repeatedly), and save the result.
Quite costly operation however but easy to implement.
0
All Courses

From novice to tech pro — start learning today.