BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how can I delete a row from a txt file ???

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Mike Shkolnik
Guest





PostPosted: Tue Oct 28, 2003 10:48 am    Post subject: Re: how can I delete a row from a txt file ??? Reply with quote




If your text file is not large:

with TStringList.Create do
try
LoadFromFile(yourFileName);
i := IndexOf(yourTextString);
if i > -1 then
Delete(i);
SaveToFile(yourFileName);
finally
Free
end;

With best regards, Mike Shkolnik
EMail: [email]mshkolnik (AT) scalabium (DOT) com[/email]
http://www.scalabium.com

"SAN CAZIANO" <akalb.sia (AT) tiscalinet (DOT) it> wrote:
Quote:
I have to search a text in a txt file and if I found it I have to delete the
row (the row does't have duplicate value, it is always unique) that match
the text founded.

Please give me a valid suggestion as soon as possible, thanks.




Back to top
SAN CAZIANO
Guest





PostPosted: Tue Oct 28, 2003 11:29 am    Post subject: how can I delete a row from a txt file ??? Reply with quote



I have to search a text in a txt file and if I found it I have to delete the
row (the row does't have duplicate value, it is always unique) that match
the text founded.

Please give me a valid suggestion as soon as possible, thanks.


Back to top
Kurt Barthelmess
Guest





PostPosted: Tue Oct 28, 2003 2:51 pm    Post subject: Re: how can I delete a row from a txt file ??? Reply with quote



"SAN CAZIANO" <akalb.sia (AT) tiscalinet (DOT) it> wrote:

Quote:
I have to search a text in a txt file and if I found it I have to delete the
row (the row does't have duplicate value, it is always unique) that match
the text founded.

Ultimately, you must rewrite the file. There is no way to "squeeze" a
line out of it short of copying everything after the deleted line to
where the deleted line was. If you are using TStream's, the CopyFrom
method makes that easy.

Good luck.

Kurt


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.