title: SMTP Send is locking up my files - c#
body: <p>I have a function thats sending messages ( a lot of them) and their attachments. </p>
  
  <p>It basically loops through a directory structure and creates emails from a file structure for example</p>
  
  <pre><code> c:\emails\message01
                  \attachments
   c:\emails\message02
                  \attachments
  </code></pre>
  
  <p>The creation of the messages takes place using .net c#, standard stuff. </p>
  
  <p>After all messages are created... I have another function that runs directly afterwards that copies the message folder to another location. </p>
  
  <p>Problem is - files are locked...</p>
  
  <p>Note: I'm not moving the files, just copying them....</p>
  
  <p>Any suggestions on how to copy locked files, using c#?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I have this add attachments method</p>
  
  <pre><code>    private void AddAttachments(MailMessage mail)
      {
          string attachmentDirectoryPath = "c:\messages\message1";
          DirectoryInfo attachmentDirectory = new DirectoryInfo(attachmentDirectoryPath);
          FileInfo[] attachments = attachmentDirectory.GetFiles();
          foreach (FileInfo attachment in attachments)
          {
              mail.Attachments.Add(new Attachment(attachment.FullName));
          }
      }
  </code></pre>