c# - How to check if something already exists in a text file -


code snippet below

    using (system.io.streamwriter file = new                        system.io.streamwriter("c:\\users\\public\\usernames.txt", true))     {     file.writeline();     }      int usertype = 0;     tring retrievedusername = string.empty;  using (system.io.streamreader fileusername = new system.io.streamreader("c:\\users\\public\\usernames.txt")) {     retrievedusername = fileusername.readtoend(); } 

with edits above code, how can check if exists in text file? or return true or false bool. way can check if string matches text in text file, not contain it. ( msdn big pain read.... half of have no understanding of )
in advance!

so want if username in line of file, can use file.readlines + contains, example

bool containsuser = file.readlines(path).contains(username); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -