Solved

Delete string from text file

Posted on 2002-04-29
1
134 Views
Last Modified: 2012-05-04
how do i make my programme delete the string 'File was CFFed' that was found in 'C:\File data.txt'. the command will run when i click on a button.
0
Comment
Question by:tyfing
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6977276
hi,
heres one way:

procedure TForm1.Button1Click(Sender: TObject);
var
 sl : tstringlist;
  i : integer;
  s1 : string;
  SearchStr : string;
  place : integer;
begin
sl := tstringlist.create;
SL.LoadFromFile('C:\Winzip.log');
  SearchStr := 'File was CFFed';
  for i := 0 to SL.Count -1 do begin
    s1 := SL.Strings[i];
    Repeat
      Place := pos(SearchStr, s1);
      if place > 0 then begin
        Delete(s1, Place, Length(SearchStr));
        SL.Strings[i] := s1;
      end;
    until place = 0;
  end;
  sl.SaveToFile('C:\Winzip.log');
  sl.free;
end;
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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