none
SaveBinaryDirect

    Question

  • hi,

    When I try to add an attachment to and listitem I get and error The remote server returned an error: (409) Conflict.

    This is my code what am I doing wrong?

          sp.ClientContext clientContext = new sp.ClientContext(settings.SharePointUrl);
          string attUrl = settings.SharePointUrl + "Lists/" + settings.SharePointListName +"/Attachments/" + itemId + "/" + att.Name;
          Uri url = new Uri(attUrl);
          
          byte[] byteArrayAtt = System.IO.File.ReadAllBytes(att.FullName);
          do
          {
            using (MemoryStream memoryStream = new MemoryStream())
            {
              memoryStream.Write(byteArrayAtt, 0, (int)byteArrayAtt.Length);
              memoryStream.Seek(0, SeekOrigin.Begin);
              sp.File.SaveBinaryDirect(clientContext, url.AbsolutePath, memoryStream, true);
              break;
            }
          } while (true);
    
    
    Monday, December 20, 2010 7:10 PM

Answers

All replies