i have a two strings with a c# program named eMail & password and i have a regex that check if the text match or not, if the two strings are verified it will save these two strings in 2 different textfiles this is my code:
string eMail = textBox1.Text;
string password = textBox2.Text;
Regex email_Regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
Match email_Match = email_Regex.Match(eMail);
Regex password_Regex = new Regex("^.{4,20}$");
Match password_Match = password_Regex.Match(password);
if (!email_Match.Success)
{
MessageBox.Show(this,
"Please Enter A Valid Email Adress !",
"Error While Connecting !",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button3);
}
else if (!password_Match.Success)
{
MessageBox.Show(this,
"Please Enter A Valid Password !",
"Error While Connecting !",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button3);
}
else if (password_Match.Success)
{
File.WriteAllText(@"D:\Password.txt", password);
}
else if (email_Match.Success)
{
File.WriteAllText(@"C:\Email.txt", eMail);
}
when I debug and i test my program only one textfile is created it the first one ( only the Password.txt ) Any solution ?