Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 manipulating a specific line in a text file

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2007-03-08 : 18:40:56
i dear,

I have a text file with carriage returns (enter as lines seperators). I have used readline and writeline but my need is to :

change or delete specific line in the text file.

For example the line number 16 or the line that has the string value: "this is the content of the line to be replaced or deleted"

Thanks a lot.

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-03-08 : 20:52:23
read the lines into memory, skipping the line you don't need. Then write the remaining lines back out to the file, overwriting it.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

rtutus
Aged Yak Warrior

522 Posts

Posted - 2007-03-08 : 21:14:31
i thought there might be a way to do that directly by pointing to the lines without ovewryting the whole file. I am concerned about performance issues since my file will have thousands of lines. But may be that a DB d be the way to go.
Thanks a lot.
Go to Top of Page
   

- Advertisement -