I need to make a program where the user's input always adds a new line of code (string) to a file. But what I keep getting is each type the user writes a string into a file, the previous code/string is deleted. How do I continually keep adding strings to this one file without the previous code going to trash?
0
fs API: Adding string without deleting previous string in file
Started by moneymaster2012, Mar 16 2017 12:15 AM
3 replies to this topic
#1
Posted 16 March 2017 - 12:15 AM
#2
Posted 16 March 2017 - 12:22 AM
you want to use
"a" being the important part, this appends to the end of the file.
you can then use
file = fs.open("file_path_here", "a")
"a" being the important part, this appends to the end of the file.
you can then use
file.writeLine("This line is now appended!")to append to the end of the file.
Edited by FuzzyLitchi, 16 March 2017 - 12:22 AM.
#3
Posted 16 March 2017 - 12:47 AM
FuzzyLitchi, on 16 March 2017 - 12:22 AM, said:
you want to use
"a" being the important part, this appends to the end of the file.
you can then use
file = fs.open("file_path_here", "a")
"a" being the important part, this appends to the end of the file.
you can then use
file.writeLine("This line is now appended!")to append to the end of the file.
#4
Posted 16 March 2017 - 02:37 PM
You're welcome
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users