Click here to Skip to main content
14,825,162 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello!

Does anyone knw how to write to a specified location of an existing text file in C#?
I will be very thnkful if anyone can commnt on this.Thank u and Happy Easter to all!!!
Posted
Comments
Sergey Alexandrovich Kryukov 25-Apr-11 12:49pm
   
"Does anyone knw" simple sounds offensive. Of course, all the experts working with C# know!
The question is too simple, not even matching the lower level of the question.
--SA
Nish Nishant 25-Apr-11 12:50pm
   
:-)
Sameera Fonseka 26-Apr-11 6:13am
   
Hi!
Tkx.I ws usn java n vb..so new to c#..n im nt an ordnry sftwre devlpr.bcz ma fld s electrncs desgn..tkx alt for ur hlps.thats y say "Does anyone knw"..rly sry if you(SAKryukov) got hurt.tkx again to Nishant Sivakumar.

1 solution

You can only do this if the new text is the same length as the original text being replaced. If that's true, then lookup FileStream.Seek on MSDN (link below).

http://msdn.microsoft.com/en-us/library/system.io.filestream.seek(v=VS.100).aspx[^]
   
Comments
Sergey Alexandrovich Kryukov 25-Apr-11 12:49pm
   
As simple as that, my 5.
--SA
Nish Nishant 25-Apr-11 13:05pm
   
Thanks SA.
Kim Togo 25-Apr-11 13:04pm
   
Good answer, my 5.
Nish Nishant 25-Apr-11 13:05pm
   
Thank you, Kim.

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