gwarguitar
asked on
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?
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?
ASKER
umm... not seeing anything in there that helps me with my problem.
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.functionx.com/csharp/fileprocessing/operationsonfiles.htm
http://www.codeproject.com/useritems/Read_a_certain_line.asp
http://www.codeproject.com/file/