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

submitted by youseflayousefla(675) 5 years, 1 month ago

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#?

add a comment |category: |Views: 20

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story