I am trying to write a text file that is in use.
Dim fs As TextOutputStream = TextOutputStream.Create(f)
causes the 104.
It somehow makes sense because it is used by another program and when I close this program, I can normally write the file.
However, I noticed that competitor/other Apps can write the file while in use. I can even open Textedit, change something and save the file. While my Xojo App can’t.
Is there a way that I can somehow force Xojo to normally write the file like other Apps do?
Have you tried a binarystream?
Apple’s TextEdit uses some high level APIs to load the contents, perhaps it’s that API which allows reading while another application has tagged the file as in use?
Same ErrorNumber 104 with binarystream.
Loading the file goes ok, saving gives ErrorNumber 104.
edit: … it also won’t allow me to delete the file so Move/CopyFileto won’t work either. But a normal cp command works fine. I guess writing to a Temp file and then Shelling out will do the trick. But it’s still strange that Xojo gives me the 104.
Sorry I misunderstood, you’re trying to write to a file while it’s locked by other apps.
A couple of things spring to mind:
Xojo is obeying the inUse flag of the file, while other apps are not.
Perhaps a different API allows this (high or low level). You can get the source code to TextEdit and see what it uses.
Perhaps it’s an atomic write? Write to a temp file first, then replace the original file.