我之前的问题也涉及文件上传,但现在我正试图解决c#asp.net中zip / rar文件格式的文件上传问题
代码:
protected void cmdUpload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string extension =
System.IO.Path.GetExtension(FileUpload1.FileName).ToUpper();
if (extension == "zip" || extension == "rar" || extension == "tar")
{
FileUpload1.SaveAs(Server.MapPath("FileArchive") + "\\" +
FileUpload1.FileName);
Label1.Text = "Uploaded successfully";
}
else
{
Label1.Text = "Cannot accept file. Invalid Type.";
}
}
}
我写了这个,但它有用。 有没有一种特殊的方法可以处理压缩文件上传?