 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Mike Shkolnik Guest
|
Posted: Tue Oct 28, 2003 10:48 am Post subject: Re: how can I delete a row from a txt file ??? |
|
|
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
|
Posted: Tue Oct 28, 2003 11:29 am Post subject: how can I delete a row from a txt file ??? |
|
|
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
|
Posted: Tue Oct 28, 2003 2:51 pm Post subject: Re: how can I delete a row from a txt file ??? |
|
|
"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 |
|
 |
|
|
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
|
|