Error!
Success!

How to insert text at a specified line number in a file using C#?

0
kicks

How to insert text at a specified line number in a file using C#?  (Unpublished)

System.IO.StreamWriter allows you to write text to a file easily if you are creating the file and know the order of the lines. However, what if you are trying to edit a file? For example, you need to insert a text at a specified line number in an existing text file. Say you have a text file that contains: 1. Orange 2. Banana <---- Want to Insert: 3. Apple 4. Grapefruit 5. Kiwi And say you want to insert the text "3. Apple" between line 2 & 4, how do you do that in C#?


Kicked By:
Drop Kicked By: