Last post Aug 10, 2009 01:01 PM by rkeslar
Aug 07, 2009 12:11 PM|rkeslar|LINK
I'm able to append text to the end of a file, but how do you prepend text to the beginning? This is the code I'm using to append text:
Dim objWriter As New System.IO.StreamWriter(fname, True)
Aug 07, 2009 02:12 PM|atconway|LINK
The 'append' parameter on the StreamWriter class does not seem to have any exposd method to allow you to dictate if the text is prepended or appended. It seems that the text will
only be appended to the end of the file.
I think the solution to this is to use a 'StreamReader' to read out all of the contents of your existing text file, then start a new file (or StreamWriter) adding the new text you want at the begining of the file, and then use the StreamWriter
as you have to append on all of the old text.
If this needs to happen repeatedly, you could put this all in a loop, and it should work fine.
Aug 10, 2009 01:01 PM|rkeslar|LINK
Thanks. That's what I ended up doing and it worked fine.