title: The specified package is invalid. The main part is missing
body: <p>Below given is a merge function which is intended to merge all docx files in a folder and produce the merged file. </p>
  
  <pre><code>public  void Merge()
  {  
      try
      {
  
          string sid = Request.QueryString["studid"];
          string stud = sid.ToString();
  
          string ds = HttpContext.Current.Server.MapPath(("~\\StudentBinder") + "\\Temp4\\");
          if (Directory.Exists(ds))
          {
              DirectoryInfo d = new DirectoryInfo(ds);
              FileInfo[] Files = d.GetFiles("*" + stud + "*.docx");
  
                // stud added for differentiating b/w users
  
              string[] filepaths = new string[Files.Length];
              int index = 0;
  
              foreach (FileInfo file in Files)
              {
                  filepaths[index] = file.Name;
                  index++;
              }
  
  
                  using (WordprocessingDocument myDoc = WordprocessingDocument.Open(Server.MapPath(filepaths[0]), true))
  
                  {
                      for (int i = 1; i &lt; filepaths.Length; i++)
                      {
                          MainDocumentPart mainPart = myDoc.MainDocumentPart;
                          string altChunkId = "AltChunkId" + i.ToString();
                          AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.WordprocessingML, altChunkId);
                          using (FileStream fileStream = File.Open(@filepaths[i], FileMode.Open))
                          {
                              chunk.FeedData(fileStream);
                          }
                          AltChunk altChunk = new AltChunk();
                          altChunk.Id = altChunkId;
                          mainPart.Document.Body.InsertAfter(altChunk, mainPart.Document.Body.Elements&lt;DocumentFormat.OpenXml.Wordprocessing.Paragraph&gt;().Last());
                          mainPart.Document.Save();
                          myDoc.Close();
                      }
                  }
          }
      }
      catch (Exception ex)
      {
      }
  }
  </code></pre>
  
  <p>but the line </p>
  
  <pre><code>using (WordprocessingDocument myDoc = WordprocessingDocument.Open(Server.MapPath(filepaths[0]), true))
  </code></pre>
  
  <p>raises the error <strong>The specified package is invalid. The main part is missing.</strong></p>
  
  <p>I dont know  what goes wrong in that statement. any suggestions are welcomed. Thanks in advance.</p>