SharePoint列表附件,如何覆盖它们
关于SharePoint的快速问题。。。。 我需要使用SharePoint sdk更新列表上的附件,但每次删除旧附件并添加新附件时,都不会添加新文档。下面是我的代码SharePoint列表附件,如何覆盖它们,sharepoint,Sharepoint,关于SharePoint的快速问题。。。。 我需要使用SharePoint sdk更新列表上的附件,但每次删除旧附件并添加新附件时,都不会添加新文档。下面是我的代码 /* Delete the attachment first and create a new attachment.*/ string fileName = newAttachmentName.Substring(0, newAttachmentName.IndexOf("."));
/* 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();
也许这会有所帮助: 以下内容不起作用:
SPAttachmentCollection attachments = listitem.Attachments;
foreach (SPFile file in attachments)
{
// Do something
}
以下方法确实有效:
SPFolder folder = web.Folders["Lists"].SubFolders[list.Title].SubFolders["Attachments"].SubFolders[listitem.ID.ToString()];
foreach (SPFile file in folder.Files)
{
// Something useful here
}
也许这会有所帮助: 以下内容不起作用:
SPAttachmentCollection attachments = listitem.Attachments;
foreach (SPFile file in attachments)
{
// Do something
}
以下方法确实有效:
SPFolder folder = web.Folders["Lists"].SubFolders[list.Title].SubFolders["Attachments"].SubFolders[listitem.ID.ToString()];
foreach (SPFile file in folder.Files)
{
// Something useful here
}
覆盖新文件的位置创建新附件实例(附件1)
覆盖新文件创建新附件实例(attachment1)链接不会退出链接。没过多久就找到了:)链接没有退出链接。没过多久就找到了:)