I am trying to:
1. read all contents in an existing .txt file
2. wipe out all said contents, and replace them with new contents
3. update/save the file
How do I do this without deleting the file? So far I have come up with this script but I admit, I have been scratching my head over this one for months on and off:
Code: Select all
FileRead, Contents, C:\MyTextFile.txt ;read all text in the file
StringReplace, NewTextVar, Contents, %Contents%, ThisIsTheNewText, All ;assign "ThisIsTheNewText" as the new text to be written to the file
Contents= ;wipe out all original text in the file
FileAppend, %Contents%%NewTextVar%, C:\MyTextFile.txt ;write the new text to the file
Return