title: Some times PDF files get corrupted after File Upload C#
body: <p>I am trying to upload PDF files. Only sometimes uploaded file gets corrupt. When I open that file on Adobe or browser. its says <strong>Insufficient data for an images</strong></p>
  
  <p><a href="https://i.stack.imgur.com/h53oD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h53oD.jpg" alt="Error Pdf"></a></p>
  
  <p>This problem is not for all the uploads.  When I tried to upload the same file again its works perfectly.
    I am not able to replicate the issue so that I can know why this type of issue occurring
      I am using below code to save the file</p>
  
  <pre><code>FileUpload upload = GridView1.Rows[index].FindControl("FileUpload1") as FileUpload;
  
  if (upload.HasFile)
  {
       string nameoffile = upload.FileName;
       Random ran = new Random();
       int forReference = ran.Next();
  
       string[] strfileArray = nameoffile.Split('.');
  
       nameoffile = strfileArray[0] + "" + forReference + ".pdf";
       upload.SaveAs(path + "/" + nameoffile);
  }
  else
  {
       upload.SaveAs(path + "/" + nameoffile);
  }
  </code></pre>
  
  <p>Note: We are running this appliaction on  Azure VM. This code was works without any issue on previous server. since we migrated to Azure </p>