I'm trying to append text to the end of a specific line of text in a text file in C#, I'm not getting the desired results. Here's the file
23 - 2546853
24 - 2345548
25 - 3458394
The first number is the Id that the numbers that follow are associated with. The problem comes in when I try to add a new number to an existing Id it does the following:
23 - 2337980,
232789423,
423424898,
24 - 2345548
25 - 3458394
instead of:
23 - 2337980,232789423,423424898,
24 - 2345548
25 - 3458394
Right now I'm using this solution to get the position of the line number, after that when I write to the text file after reading the position of the ID's line number, I use the value of the line number position as an argument for the StreamWriter.BaseStream.Seek()
method and then I call the StreamWriter.Write()
method. All help will be much appreciated.