title: OpenXml Cannot open package because FileMode or FileAccess value is not valid for the stream
body: <p>The stream comes from an html form via ajax <code>var jqXHR = data.submit();</code></p>
  
  <pre><code>public static GetWordPlainText(Stream readStream,string filePath)
  {
     WordprocessingDocument.Open(readStream, readStream.CanRead);
  }
  [HttpPost]
  public ActionResult FileUpload() 
  {
   var MyFile = Request.Files[0];
   if (Request.Files.Count &gt; 0 &amp;&amp; MyFile != null)
   {
    GetWordPlainText(Request.InputStream);
   }
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Cannot open package because FileMode or FileAccess value is not valid
    for the stream.</p>
  </blockquote>
  
  <p>I google <em>Cannot open package because FileMode or FileAccess value is not valid for the stream</em> but can't find anything useful. Any ideas?</p>
  
  <p>PS: Initially I simplified the code to be posted here to much. Added the if statement so that it would erase the concern by Sten Petrov. I hope Request.File.count>0 does address his concern... I still have the same problem...</p>
  
  <h1>UPDATE</h1>
  
  <p>As a work around I followed the advise below and save the file to a directory then I use openxml to read it from the directory </p>
  
  <pre><code>  var MyFile = Request.Files[0];
    var path = Path.Combine(Server.MapPath("~/App_Data/temp"), MyFile.FileName);
                  using (MemoryStream ms = new MemoryStream())
                  {
                      //if file exist plz!!!! TODO
  
                      Request.Files[0].InputStream.CopyTo(ms);
                      System.IO.File.WriteAllBytes(path, ms.ToArray());
                  }
  </code></pre>
  
  <p>then <code>WordprocessingDocument.Open</code> has a implementation for filepath so
  <code>WordprocessingDocument.Open(path);</code> hope you get the idea of what I did for future people that have problems. </p>