- Home /
Delete or replace specific line from a file.
I'm trying to delete a specific line from a .txt file and replace it with another line. So this line will have an ID and I can search for it but I'm not sure how to delete, or better yet, replace that line with a new line.
I've looked at File.AppendText() and other methods but they aren't helping. I'm using Javascript. Can anyone help please?
Comment
Answer by drudiverse · Mar 19, 2016 at 08:55 AM
using system io
function lineChanger( newText: String, fileName :String, line_to_edit: int)
{
var arrLine : String[] = File.ReadAllLines(fileName);
arrLine[line_to_edit - 1] = newText;
File.WriteAllLines(fileName, arrLine);
}
Your answer

Follow this Question
Related Questions
How to delete file inside my script? 1 Answer
How I can delete a line of UI text 0 Answers
How to delete everything at Application.persistentDataPath? 3 Answers
Mobile delete file with specific file extension 1 Answer
Delete Folder? 2 Answers