title: How can I upload a pdf file?
body: <p>I have to upload a .pdf file in a web application using the <code>FileUpload</code> control. I have tried this code, but it has some problems. Can anyone help me with this?</p>
  
  <pre><code> protected void Button1_Click(object sender, EventArgs e)
   {
        if (FileUpload1.HasFile)
        {
             if (FileUpload1.PostedFile.ContentType == ".pdf")
             {
                  string path = Server.MapPath(".") + "\\" + FileUpload1.FileName;
                  FileUpload1.PostedFile.SaveAs(path);
                  Label6.Text = "File Uploaded Successfully...";
                  StreamReader reader = new StreamReader(FileUpload1.FileContent);
                  string text = reader.ReadToEnd();
             }
             else
                  Label6.Text = "Upload .pdf File";
        }
        else
             Label6.Text = "Upload file";
   }
  </code></pre>