Discussion (5)2
Log in or sign up to continue

E.g.:

fileName="C:\temp\test.txt"
f=##class(%FileCharacterStream).%New()
f.Filename=fileName
f1=##class(%FileCharacterStream).%New()
f1.Filename=fileName
   
f.Write("start ")
f.CopyFrom(f1)
f.Write(" end")

f.SaveStream()
f="",f1=""

Result:

test.txt (Before): bla-bla-bla
test.txt (After): start bla-bla-bla end

That's what I though, but it seemed slow.

Isn't there anyway to move the stream cursor back without erasing  the existing data?
And if not, couldn't that be done using a device directly?

Gevorg, you can give Vitaliy credit for the answer by clicking the checkmark alongside the answer header:

This will also mark your question as "answered".

Not possible, due to data in the file stored sequentially. If you want to insert some data in any place, it means you should move all next data on the disk too. So, the only way it is a new file.