c# - Find Line that Contains String and Delete that Line in .txt file -
my goal erase line matches string donatorplayer
if (targetplayer == null) { player.message("that not online. please try again when online may notified in due time."); } else { //switch (donationcheck) //{ foreach (string line in lines) { whichloopdelete += 1; if (line == donatorplayer) { switch (donationcheck) { case 0: lines[whichloopdelete] = null; file.delete("donators.txt"); file.create("donators.txt"); donationcheck = 1; break; case 1: textwriter tw = new streamwriter("donators.txt"); //here need delete line break; } } } //} }
just use:
lines = lines.where(line => !line.equals("donatorplayer")).toarray();
Comments
Post a Comment