if (FileUpload1.FileContent.ContentType == "application/vnd.ms-excel")
{
//Excel文件上传代码
}
else
{
//上传的不是Excel文件
}
string fileExtension = Path.GetExtension(FileUpload1.FileName);
if (fileExtension == ".xls" || fileExtension == ".xlsx")
{
//Excel文件上传代码
}
else
{
//上传的不是Excel文件
}
if (FileUpload1.FileContent.ContentType == "application/vnd.ms-excel" &&
(Path.GetExtension(FileUpload1.FileName) == ".xls" || Path.GetExtension(FileUpload1.FileName) == ".xlsx"))
{
//Excel文件上传代码
}
else
{
//上传的不是Excel文件
}
上一篇:asp.net中未显示解析器错误