The following methods can be used to write all the lines of text to text file and to read all the lines of text from text file.
System.IO.File.WriteAllLines(fileName,new string[]{"username","password"});
string[] userData = System.IO.File.ReadAllLines(fileName);
Here, I have not used username =, password =. It can be used, then you have to extract the relevant portion from the string.
But, the major point is, if the username and in particular password is written to the text file as it is, any body can easily access and the whole purpose of authentication is defeated.
This aspect is explained by
SAKryukov here
verify user name and password in c# form[
^]