Solved

Delete line from text file

Posted on 2006-07-08
4
228 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
ID: 17067228
0
 

Author Comment

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

Expert Comment

by:anarki_jimbel
ID: 17078061
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
ID: 17276302
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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