Solved

Delete line from text file

Posted on 2006-07-08
4
223 Views
Last Modified: 2010-04-16
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?
0
Comment
Question by:gwarguitar
4 Comments
 
LVL 6

Expert Comment

by:MuhammadAdil
Comment Utility
0
 

Author Comment

by:gwarguitar
Comment Utility
umm... not seeing anything in there that helps me with my problem.
0
 
LVL 29

Expert Comment

by:anarki_jimbel
Comment Utility
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
 
LVL 10

Accepted Solution

by:
Ready1 earned 50 total points
Comment Utility
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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now