check if string exists in a file

后端 未结 7 1687
猫巷女王i
猫巷女王i 2021-02-09 19:36

I have the following piece of code which opens a text file and reads all the lines in the file and storing it into a string array.

Which then checks if

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-09 20:13

    Sounds overly complex, no reason to check by line or anything if you want to know if a string is present in a file. You can replace all of your code simply with :

    if(File.ReadAllText(path).Contains(domain))
    {
        MessageBox.Show("There is a match");
    }
    

提交回复
热议问题