StreamWriter in C#!

Hoshmand Noori 1 Reputation point


how to delete or update a line in a text file using streamwriter ?


You shouldn't care about the tags below :) ..

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
27,083 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. mike m ( 81 Reputation points

    What about using Linq to do something like that

    string item = usertxt2.Text.Trim();
    var lines = File.ReadAllLines(usersPath).Where(line => line.Trim() != item).ToArray();
    File.WriteAllLines(usersPath, lines);

    from here:

    0 comments No comments