Inserting Text into a Text File
[Originally posted by Sean Naghibi]
I am writing a utility in VB which opens a text file say:
and inside the file we have the following:
what I need it to do is to count line 12 and if it is True then
insert the following
in line 19
I would be greatful if anyone could help me.
Re:Inserting Text into a Text File
[Originally posted by Greg DeBacker]
The easiest way to do this is to open the first file and read it line by line. At the same time open a new, temp file (you can name it anything) and write each line to the temp file. When you get to line 12 (or whatever) you then start writing the empty quotes to the temp file. Then continue reading the remainder of the original file and write to the temp file after the empty quotes. When all is done the temp file should look just like the original except that it has the new lines added to it. You can then delete the original file and rename the temp file giving it the name of the original file.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center