title: SharePoint: How to add an attachment to a list item programatically?
body: <p>I have the following code:</p>
  
  <pre><code>  SPList list = web.Lists[this.ListName];
    SPListItem item = list.Items.Add();
  </code></pre>
  
  <p>now what I want to do is:</p>
  
  <pre><code>   FileInfo[] attachments = attachmentDirectory.GetFiles();
          foreach (FileInfo attachment in attachments)
          {
             // Add the attachment from file system to the list item...
  
          }
  </code></pre>
  
  <p>How do I convert a normal file to a byte array?</p>