I'm taking a C# beginners course at my university this semester, and for my final project I'm trying to make a login and register for my "course database". I got the login working recently, but ever since I added the register form to the project the login stopped working and instead gave me errors. I have tried without avail to get login working again, but I have had no such luck. I was hoping you guys could help me out.

Below is what I've got so far.

--

This is the login portion. I use streamreader to read login information from text files in the debug folder of my visual c# project. If the login is successful, then the database form is displayed (which I have not shown here). If not, then invalid input is displayed.

--

namespace CourseDataFinal3
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private int userID;
private string password;

private void CheckText()
{
try
{

StreamReader loginFile;
loginFile = File.OpenText("logininfo.txt");

int.TryParse(loginFile.ReadToEnd(), out userID);

loginFile.Close();

StreamReader passwordFile;
passwordFile = File.OpenText("passwordInfo.txt");

password = passwordFile.ReadToEnd();

passwordFile.Close();

}
catch
{
MessageBox.Show("Error in reading data");
}


}




private void loginButton_Click(object sender, EventArgs e)
{
CheckText();
Form1 myDataForm = new Form1();
int userInput;
string passwordInput;
int.TryParse(userLoginText.Text, out userInput);
passwordInput = passwordText.ToString();

if (userInput == userID && passwordInput == password)
{
myDataForm.ShowDialog();
}

else
{
MessageBox.Show("Invalid input");
}


}

private void registerButton_Click(object sender, EventArgs e)
{
RegisterForm myRegForm = new RegisterForm();
myRegForm.ShowDialog();
this.Hide();
}

}
}

--

And this is the register portion. It uses streamwriter to write to the same files, which the login form reads from

--

namespace CourseDataFinal3
{
public partial class RegisterForm : Form
{
public RegisterForm()
{
InitializeComponent();
}

private void cancelButton_Click(object sender, EventArgs e)
{
this.Close();
}

private void regButton_Click(object sender, EventArgs e)
{
try
{
//Commented out for future reference:
//RegisterForm myRegForm = new RegisterForm();

//Errors or items still not working:
//Still registers blanks, error msg will not show

StreamWriter loginFile;
loginFile = File.AppendText("logininfo.txt");
loginFile.WriteLine(usernameTextBox.Text);
loginFile.Close();
StreamWriter passwordFile;
passwordFile = File.AppendText("passwordInfo.txt");
passwordFile.WriteLine(passTextBox.Text);
passwordFile.Close();

MessageBox.Show("Thank you for registering!");
usernameTextBox.Text = "";
passTextBox.Text = "";
usernameTextBox.Focus();

}
catch
{
MessageBox.Show("Please fill out both; a username and a password.");
}
}
}
}

Any idea's?