This content has been marked as final. Show 6 replies
The best way is usually to delete the file before re-writing. You can begin writing from the beginning of the file instead of appending, but you'll run into problems if your new file is shorter than your old one - you'll see the 'remains' of the old one left at the end. So I find it's usually best to just delete and re-write.
hope this helps,
Thanks Ben. So, how do I delete the file?:)
You can use Buddy API xtra
use Result = baDeleteFile( FileName )
OK I have:
gFileioObject = new (xtra "FileIO")
openFile (gFileioObject, ("textFile.txt"), 0)
fullText = string(readFile (gFileioObject))
then I change something in fullText and add it to a text memebr then
writeString (gFileioObject, member("modified").text)
gfileioObject = 0
Is that the right process? As it's not working.
Egyptian Art wrote:
> You can use Buddy API xtra
> use Result = baDeleteFile( FileName )
Thanks. I found 'gFileioObject.delete()' which I think should delete the
text but haven't got it working.
Process is almost there. Everything is fine from creating the Xtra
instance, opening the file, grabbing the text, then deleting the file.
Though once you've deleted the file, you need to recreate it and then
reopen as follows:
-- create and open the file
After that is done you can write too the file and all should be OK.
Director Lecturer / Consultant