s fileName="C:\temp\test.txt"
s f=##class(%FileCharacterStream).%New()
s f.Filename=fileName
s f1=##class(%FileCharacterStream).%New()
s f1.Filename=fileName
d f.Write("start ")
d f.CopyFrom(f1)
d f.Write(" end")
d f.SaveStream()
s f="",f1=""
Result:
test.txt (Before): bla-bla-bla
test.txt (After): start bla-bla-bla end
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.
E.g.:
Result:
Thank!
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.