Asp.Net上传文件并配置可上传大文件的方法

  protected void btnsave_Click(object sender, EventArgs e)

  {

  StringBuilder sb = new StringBuilder();

  if (FileUpload1.HasFile)

  {

  try

  {

  sb.AppendFormat(" Uploading file: {0}", FileUpload1.FileName);

  //saving the file

  FileUpload1.SaveAs("" + FileUpload1.FileName);

  //Showing the file information

  sb.AppendFormat("
Save As: {0}", FileUpload1.PostedFile.FileName);

  sb.AppendFormat("
File type: {0}", FileUpload1.PostedFile.ContentType);

  sb.AppendFormat("
File length: {0}", FileUpload1.PostedFile.ContentLength);

  sb.AppendFormat("
File name: {0}", FileUpload1.PostedFile.FileName);

  }

  catch (Exception ex)

  {

  sb.Append("
Error
");

  sb.AppendFormat("Unable to save file
{0}", ex.Message);

  }

  }

  else

  {

  lblmessage.Text = sb.ToString();

  }

  }