我正在使用带有C#的aspx网页,我试图指向一个目录但是当我这样做时,我得到了#34;找不到文件&#c; \ windows \ system32 \ INETSRV \ 2.txt'"但在我的C#代码中,我正在使用:
currentStaffPosition = rolesRadioButton.SelectedItem.ToString();
string currentStaffDirectory = Server.MapPath(@"~\admin\applications\" + currentStaffPosition);
此代码应指向C:\ inetpub \ wwwroot \ admin \ applications 任何人都知道为什么或如何发生这种情况?提前谢谢。
附加代码:
string currentStaffPosition = null;
string currentStaffDirectory = null;
protected void rolesRadioButton_SelectedIndexChanged(object sender, EventArgs e)
{
dropDownList.Items.Clear();
currentStaffPosition = rolesRadioButton.SelectedItem.ToString();
string currentStaffDirectory = Server.MapPath(@"~\admin\applications\" + currentStaffPosition);
string[] staffApplications = Directory.GetFiles(currentStaffDirectory);
foreach (string apps in staffApplications)
{
dropDownList.Items.Add(new ListItem(Path.GetFileNameWithoutExtension(apps)));
}
}
protected void dropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
string currentSelectedApp = currentStaffDirectory + dropDownList.SelectedItem + ".txt";
string currentLine;
StreamReader applicationReader = new StreamReader(currentSelectedApp);
while ((currentLine = applicationReader.ReadLine()) != null)
{
if (currentLine.Contains("First Name:"))
forumUsernameTextBox.Text = currentLine.Replace("First Name: ", "");
}
applicationReader.Close();
}