title: Unable to add new row to exisitng table in word document using WordprocessingDocument
body: <p>I have a word document in which there is table added. I want to access that document and add new blank row to the table which is already in it. I referred <a href="https://stackoverflow.com/questions/15622489/add-a-row-to-an-existing-table-in-a-word-document-open-xml">this</a> reference link and created below code:</p>
  
  <pre><code>static void Main(string[] args)
  {
      string filePath = "C:\\TestDoc1.docx";
      byte[] byteArray = File.ReadAllBytes(filePath);
  
      using (MemoryStream stream = new MemoryStream())
      {
          stream.Write(byteArray, 0, (int)byteArray.Length);
  
          using (WordprocessingDocument doc = WordprocessingDocument.Open(stream, true))
          {
              Body bod = doc.MainDocumentPart.Document.Body;
              foreach (Table t in bod.Descendants&lt;Table&gt;().Where(tbl =&gt; tbl.GetFirstChild&lt;TableRow&gt;().Descendants&lt;TableCell&gt;().Count() == 4))
              {
                  // Create a row.
                  TableRow tr = new TableRow();
                  t.Append(tr);
              }
  
          }
          // Save the file with the new name
          File.WriteAllBytes("C:\\TestDoc2.docx", stream.ToArray());
      }
  } 
  </code></pre>
  
  <p>However, code does not throw any error. But when I open TestDoc2.docx I am getting the below error:</p>
  
  <p><img src="https://i.stack.imgur.com/QmFMP.png" alt="enter image description here"></p>
  
  <p>What am I missing?</p>