hi,
Is there a way to overwrite a line in text file
thanks
Is there a way to overwrite a line
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
What you do is edit a copy of the file and overwrite the source.
You can do either:
1. Read the entire file into memory with ReadFile. Modify the required line. Then write the data out to a NEW file with WriteLn. Then delete the old file and rename the new one to the old name.
2. Read the lines in one by one with ReadLn. Output each line to a new file with WriteLn. When you get to the one you want to change, output the changes. At the end delete the old file and rename the new to old.
You can do either:
1. Read the entire file into memory with ReadFile. Modify the required line. Then write the data out to a NEW file with WriteLn. Then delete the old file and rename the new one to the old name.
2. Read the lines in one by one with ReadLn. Output each line to a new file with WriteLn. When you get to the one you want to change, output the changes. At the end delete the old file and rename the new to old.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?