title: Unable to convert file in byte array
body: <p>i have an issue when i am trying to convert a file into byte array using this code</p>
  
  <pre><code>var fileByte = new byte[pic.ContentLength];
  </code></pre>
  
  <p>it converts the file but when file is uploaded it is corrupted.
  and when i tried the another code to convert the file i.e</p>
  
  <pre><code>   var pic = System.Web.HttpContext.Current.Request.Files["ImagePath"];
     byte[] bytes = System.IO.File.ReadAllBytes(pic.FileName);
  </code></pre>
  
  <p>it thrown an exception like </p>
  
  <blockquote>
    <p>Could not find file 'C:\Program Files\IIS Express\slide2.jpg'.</p>
  </blockquote>
  
  <p>after words i'd tried for this</p>
  
  <pre><code>byte[] b = StreamFile(pic.FileName);
  
  private byte[] StreamFile(string filename)
      {
          FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
  
          Create a byte array of file stream length
          byte[] ImageData = new byte[fs.Length];
  
          //Read block of bytes from stream into the byte array
          fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length));
  
          //Close the File Stream
          fs.Close();
          return ImageData; //return the byte data
      }
  </code></pre>
  
  <p>but it also throw and exception like </p>
  
  <blockquote>
    <p>Could not find file 'C:\Program Files\IIS Express\slide2.jpg'.</p>
  </blockquote>