By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,197 Members | 1,445 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,197 IT Pros & Developers. It's quick & easy.

textFile Manipulation

P: n/a
I have a textfile with multiple line. How do i get (for example) the 1st line
or the 3rd line then change the line to something i want in C#? How do i
delete a line in C#... or backspace in a textfile? for example

1st line
2nd line
3rd line
4th Line

I want to read the 2nd line and change the string 2nd line to string 4th
line. Anyone knows how to do this? Or i want to Delete 2nd line and move up
3rd and 4th line so there will be no space.. i need the code to do this..
does anybody have the idea? thank you so much!
Mar 30 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
you can make a string array and load the all the lines to this array and
then change the array as you want and then rewrite it to the file.
"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
I have a textfile with multiple line. How do i get (for example) the 1st
line
or the 3rd line then change the line to something i want in C#? How do i
delete a line in C#... or backspace in a textfile? for example

1st line
2nd line
3rd line
4th Line

I want to read the 2nd line and change the string 2nd line to string 4th
line. Anyone knows how to do this? Or i want to Delete 2nd line and move
up
3rd and 4th line so there will be no space.. i need the code to do this..
does anybody have the idea? thank you so much!

Mar 30 '06 #2

P: n/a
Hi

You will have to read all the lines in either an Array or an ArrayList (
preferred ) and change them at will, after you are done you can just write
the lines back to disk
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Rain" <Ra**@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
I have a textfile with multiple line. How do i get (for example) the 1st
line
or the 3rd line then change the line to something i want in C#? How do i
delete a line in C#... or backspace in a textfile? for example

1st line
2nd line
3rd line
4th Line

I want to read the 2nd line and change the string 2nd line to string 4th
line. Anyone knows how to do this? Or i want to Delete 2nd line and move
up
3rd and 4th line so there will be no space.. i need the code to do this..
does anybody have the idea? thank you so much!

Mar 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.