//Step1. Import "IO" package.
using System.IO;
//Step2.Declarer Four String Variables.
string username = "";
string password = "";
string str1 = "";
string str2 = "";
//Step3.Write Two StreamReader's
Objects their Constructors & Path of the .txt Files
StreamReader sr1 = new
StreamReader(@"c:\FolderName\\ID.txt");
StreamReader sr2 = new
StreamReader(@"c:\FolderName\\Password.txt");
//Step4.Write While Loop to Read ID
& Password Files's Data.
while ((str1 = sr1.ReadLine()) != null)
{
username=str1;
}
while ((str2 = sr2.ReadLine()) != null)
{
password=str2;
}
//Step5.Write "IF" Condition
To check is ID & Password are correct.
if(txtUserID.Text==username &&
txtPasswoed.Text==password)
{
MessageBox.Show("Welcome");
}
else
{
MessageBox.Show("Invalid
UserID or Password");
}
No comments:
Post a Comment