C#C
C#3y ago
The Joker

❔ Help with StreamReader txt file

hello everybody! I'm trying to do a reading inside a .txt file, at first I type a name in a textbox when I give the command that name would be searched inside the .txt file and if it found the name it will be deleted, does anyone have any idea how do that?

private void btnDelete_Click(object sender, EventArgs e)
{
    string path = @"ADDONS\Favorites.txt";
    StreamReader fav = new StreamReader(path);

    string[] lines = File.ReadAllLines(fav.ToString());

    foreach (string line in lines)
    {
        if(line.ToString() == textbox1.Text.ToString())
        {
            line.Replace(line, "");
        }
    }
    fav.Close();
}
Was this page helpful?