namespace Project
{
public partial class Chapter_Login : Form
{
public Chapter_Login()
{
InitializeComponent();
}
private void btnLogin_Click(object sender, EventArgs e)
{
StreamReader Chapter = new StreamReader("Chapters.txt");
Chapter.ReadLine();
string[] lines = System.IO.File.ReadAllLines("Chapters.txt");
for(int i =0; i < lines.Length-1;i++)
{
foreach (string line in lines)
{
int ID = line.IndexOf("-");
int Pass = line.IndexOf("*");
string Id = txtID.Text;
if (line.Substring(0,ID) == lines[i])
{
if (line.Substring(Pass + 1) == txtPassword.Text)
{
Chapter_Home Home = new Chapter_Home();
Home.ShowDialog();
this.Close();
}
else
{
MessageBox.Show("Incorrent ID or Password");
}
}
}
}
This is what i have so far and i get an exception agruement can not be less the zero
im trying to read a txt box and compare the cotents of a txt file to see if it is in there.
the program is a windows form and user are registering for a conference so they login in and i compare it to the txt file but i cant figure out how to do so. Any help will be greatly appreciated thank you