【发布时间】:2017-10-27 01:20:00
【问题描述】:
string[] usernames;
string[] password ;
bool username;
bool passok;
bool match;
string passinp;
string userinp;
protected void Button1_Click(object sender, EventArgs e)
{
StreamReader SrUs = new StreamReader("Usernames.txt");
StreamReader SrPass = new StreamReader("Password.txt");
int i = 0;
while(!SrUs.EndOfStream)
{
usernames[i] = SrUs.ReadLine();
}
i = 0;
while(SrPass.EndOfStream)
{
password[i] = SrPass.ReadLine();
}
if (txt_pass.Text != "" && txt_username.Text != "")
{
passinp = txt_pass.Text;
userinp = txt_username.Text;
}
else
{
Label3.Text = "Missing information";
}
int j = 0;
for(i = 0;i < usernames.Length;i++)
{
if(usernames[i] == userinp)
{
username = true;
break;
}
}
for(j = 0 ; j < password.Length;j++)
{
if(password[j]==passinp)
{
passok = true;
break;
}
}
if(username && passok && i == j)
{
Label3.Text = "Logon Correct";
}
else
{
Label3.Text = "Logon Incorect";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
}
}
}
所以当我运行它时,它给了我一个错误,它找不到 txt 文件,它在 asp.net 和 Windows 表单应用程序中使用 streamreader 是否相同,我将 txt 文件放在 bin 和根文件夹中,但又是这样给我同样的错误。
【问题讨论】:
标签: c# asp.net stream streamreader reader