【发布时间】:2019-10-06 05:48:00
【问题描述】:
文件名存在且 ASP.NET C# 始终返回 false。
我一直在尝试 File.Exists
protected void Button1_Click(object sender, EventArgs e)
{
Server.MapPath("~");
string location = ("~/Uploads/");
string filename = TextBox1.Text;
string currentfile = (location + filename);
if (System.IO.File.Exists(currentfile))
{
Label1.Visible = true;
Label1.Text = "File Exists in Uploads";
}
else
{
Label1.Visible = true;
Label1.Text = "File Name Not Found";
}
}
''''
如果输入的文件名存在于 Uploads 文件夹中,我希望看到一个输出检查 TextBox1 用户输入
【问题讨论】:
-
查看
Server.MapPath