Easy way to append to file?

BlitzMax Forums/BlitzMax Programming/Easy way to append to file?

Grey Alien(Posted 2007) [#1]
Is here an easy way to append to a file instead of having to read it all in, add an extra line, then save it all back to disk again? thx


GfK(Posted 2007) [#2]
I think you can use SeekStream with StreamSize to move the pointer to the end, use WriteLine (or whatever) then close the file.


Grey Alien(Posted 2007) [#3]
sounds logical. Will test. Thanks.


Derron(Posted 2007) [#4]
Found this here some time ago:

	Function appendtext:String(filename:String, text:String) 
		If FileType(filename) = 0 Then CreateFile(filename) 
		Local Stream:TStream = OpenStream(filename)
		SeekStream(Stream, Stream.Size())
		WriteLine(stream, text) 
		CloseStream(stream) 
	End Function


bye
MB


tonyg(Posted 2007) [#5]
You might need a "~n" as well.


Grey Alien(Posted 2007) [#6]
Perfect, thanks all!