如何以编程方式将文档从网站集的文档库移动(存档)到另一个网站集

发布于 2024-12-27 14:22:27 字数 158 浏览 1 评论 0原文

当为文档库中的列设置特定值时,我必须以编程方式将文档从网站集的文档库移动(存档)到 SharePoint 2010 中另一个网站集的文档库。

是否可以在事件接收器中为这种情况编写代码?还有其他办法吗?

如果有人有任何相关的代码或链接,请分享。

提前致谢!

I have to programmatically move (archive) a document from document library of a site collection to a document library of another site collection in SharePoint 2010, when a specific value is set for a column in the doc lib.

Would it be possible to write code for this scenario in an event receiver? Is there any other way?

If anybody has any relevant piece of code or links, please share.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

太阳哥哥 2025-01-03 14:22:27

您也许可以执行复制操作,然后删除原始文件。

查看以下链接,其中讨论了将文件从一个站点复制到另一个站点的问题:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfilecollection.aspx

该示例使用一个网站集。但是,如果将源文档转换为字节数组,则始终可以实例化目标网站集并将二进制数据添加到该网站集中的文档库。

当然,复制操作应该在事件接收器内工作。但是,我不确定如果您尝试删除接收器中的文件会发生什么(可能存在并发问题)。如果删除不起作用,请考虑触发一次性计时器作业来删除文件(这将在不同的进程中发生)。

You could perhaps do a copy operation, then delete the original file.

Have a look at the following link, which discusses copying a file from one site to another:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfilecollection.aspx

The example uses one site collection. However, if you convert the source document to a byte array you can always instantiate the target site collection and add the binary data to a document library within that site collection.

Certainly the copy operation should would work within the event receiver. However, I'm not certain what will happen if you try to delete the file within the receiver (there may be concurrency issues). If the delete does not work, consider firing a one-time timer job to delete the file (which would occur in a different process).

静谧 2025-01-03 14:22:27

您可以尝试 SPExport SharePoint 类,如下根据本文复制或移动SharePoint 项目 看起来我们在 SharePoint UI 中执行的操作很少在内部使用此 API 来完成任务。此外,这种方法还取决于您是否尝试执行一次或将成为一个重复过程。

You can try SPExport Class of SharePoint, as per this Article Copy or Move SharePoint items looks like few of the Operations that we do in SharePoint UI uses this API internally to acheive the task. Also this Approach depends if you are trying to do it one time or its going to be a repeatative process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文