Click here to Skip to main content
15,877,591 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I know how to write in a text file using the code below. But it adds the given text at the first line. If I want to write at a specific line without affecting its upper lines, what should I do?

Thank you very much

               using (StreamWriter sw = new StreamWriter @"E:\Hello.txt"))
               MessageBox.Show("Writing failed");

1 solution

use the StreamWriter.BaseStream.Seek method
Share this answer
ahhashemi 27-Jul-10 5:38am    
Reason for my vote of 4
Helpful hint. Like Alwayes
Toli Cuturicu 27-Jul-10 8:30am    
then why 4 and not 5?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900