How to add string to file at nth line at 5th index using File stream
-
Hi guys, I am new to file operation in .NET.I read few articles on FileStream class.I know seek() method.But guys how can i insert some text say "xyz" at 2nd line and at 5th index.Example File1.txt --------- hello billgates how r u? --------- output : hello billgxyzates how r u? Solution wud be appreciated. Thank u in advance
Regards Chintan www.visharadsoft.com (Nothing is so purify as KNOWLEDGE)
-
Hi guys, I am new to file operation in .NET.I read few articles on FileStream class.I know seek() method.But guys how can i insert some text say "xyz" at 2nd line and at 5th index.Example File1.txt --------- hello billgates how r u? --------- output : hello billgxyzates how r u? Solution wud be appreciated. Thank u in advance
Regards Chintan www.visharadsoft.com (Nothing is so purify as KNOWLEDGE)
You can't insert text. You need to read the whole file, insert the text in memory, and write it out again. There may be a helper method that does that, but under the hood, that's what it will do. If there is a helper method, it will be a File. method ( static on the File class )
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )