Ok erm here goes, im supposed to create a simple log in application using c#, howeaver, all the records of the userIDs and PINs are in a notepad file, which means i need to use a filestream. But heres the problem, how can i make my filestream object read through every record and find the correct one and match it? I really need some help on this. Below is my code so far... but its wrong.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ATMlogin
{
public partial class Form1 : Form
{
const string FILENAME = @"C:\Users\Zest\Documents\Visual Studio 2008\Projects\atm_user\atm_user\users.txt";
//location of data file
string[] RecArray;
string recordIn;
const char DELIM = '*';
FileStream outFile;
StreamWriter writer;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string ID = Convert.ToString(user_tb.Text);
string password = Convert.ToString(password_tb.Text);
//Creating a File Stream object to Open a file called FILENAME for writing
outFile = new FileStream(FILENAME, FileMode.Create, FileAccess.Write);
//Creating a Stream Writer with the outFile File Stream object
writer = new StreamWriter(outFile);
Boolean valid = false;
try
{
recordIn = reader.ReadLine();
RecArray = recordIn.Split(DELIM);
for(ID == RecArray[0];password == RecArray[1]; )
{
MessageBox.Show("Log In is Successful");
valid = true;
}
if(valid == false)
{
MessageBox.Show("Unsuccessful Login");
}
}
catch (Exception)
{
MessageBox.Show("You Have Missed out something");
}
}
}
}