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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -