2010-08-12 6 views
0

Question rapide à propos de SharePoint .... Je dois mettre à jour une pièce jointe dans une liste en utilisant le SharePoint sdk, mais quand jamais je supprime l'ancien, et ajouter le nouveau, le le nouveau document n'est jamais ajouté. Voici mon code ...Pièces jointes de liste SharePoint, comment les remplacer

/* Delete the attachment first and create a new attachment.*/ 
      string fileName = newAttachmentName.Substring(0, newAttachmentName.IndexOf(".")); 
      //Delete Attachment 
      SPAttachmentCollection attachments = item.Attachments; 
      if (item.Attachments != null) 
      { 
       string oldfilename = attachments[0].ToString(); 

       attachments.DeleteNow(oldfilename); 
       item.Update(); 
      } 

      //AddAttachement(item, newAttachmentName, attachmentStream, true); 
      attachments.Add(newAttachmentName, contents); 
      ////attachments[0] = filename; 
      item.Update(); 

Répondre

Questions connexes