講師または学生のユーザー名とパスワードを受け入れるWindowsフォームアプリケーションを作成します。.txtからログイン資格情報を読み取る
徹底的な頭が壁にぶつかり、血が流出した後、私はより高いパワーにアピールすることに決めました。あなたは覗いている!
テキストファイルを読み込むと、私はそれが講師と学生のユーザーを区別するためのコードができる方法
Lecturer Username: nashy
Lecturer Password: studentsaremorons
Student Username: student
Student Password: imamoron
な?ここで
は私が持っているものです。
using (StreamReader login = new StreamReader("Login.txt"))
{
if (txtUserName.Text == lecUserName && txtPassword.Text == lecPassword)
{
Lecturer lec = new Lecturer();
lec.Show();
}
else if (txtUserName.Text == studUserName && txtPassword.Text == studPassword)
{
Student st = new Student();
st.Show();
}
else
{
MessageBox.Show("Inccorect User Name or Password, please enter the correct credentials");
}
}
次のコードが役立ちますと仮定します。 – LarsTech
あなたのコードは、必要なときに正確に何をしますか? lecUserName、lecPassword、studUserName、およびstudPasswordがテキストファイルから正しく割り当てられていると仮定すると、あなたのコードはそれを細かく区別する必要があります。 –
私は地上ゼロから自分のコードを投稿しました。私は文字列の行を試しました= login.ReadToEnd(); .splitを使用して ":"の後ろに区切りますが、毎回最初のユーザーにのみ登録され、2番目には登録されません。確かに私の質問は少し包括的に書かれている可能性があります – TheChannels