简体   繁体   English

如何在 SharePoint 事件接收器中将文本文件从模块复制到未创建的文档库?

[英]How to copy a text file from a module to a document library that is not created, in SharePoint event receiver?

I have a text file in module and I need to copy that file to a document library that is not existed yet, and it is going to be created in featureActivated.我在模块中有一个文本文件,我需要将该文件复制到一个尚不存在的文档库中,它将在 featureActivated 中创建。 What should I do in this situation?在这种情况下我该怎么办?

Deploy to an existing library and then calling MoveTo in event receiver.部署到现有库,然后在事件接收器中调用 MoveTo。

Sample demo:示例演示:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MyModule" Url="MyDOc">
    <File Path="MyModule\Sample.txt" Url="Sample.txt" Type="GhostableInLibrary"/>  
  </Module>
</Elements>

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {           
            SPFile file = site.OpenWeb().GetFile("MyDOc/Sample.txt");
            file.MoveTo("/Shared%20Documents/Sample.txt");

        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在使用事件接收器上传之前,如何检查库文档文件的大小 - How to check size of library document file before uploaded with event receiver 使用事件接收器更新SharePoint库中的文档元数据 - Update Document meta data in SharePoint library using Event Receiver 使用Sharepoint事件接收器在文档库中创建一个文件夹 - Create a folder in document library using Sharepoint event receiver 如何将文档库/库从一个Sharepoint服务器复制到另一个 - How to copy document library/libraries from one Sharepoint server to another 事件接收器未触发-文档库 - Event Receiver not firing -Document Library 如何将事件接收器附加到生产服务器上的列表/文档库? - How to attach an Event Receiver to a List/Document Library on Production server? 如何在添加了SharePoint 2013的文件上创建事件接收器更改权限 - How to create an event receiver change permisions on file added sharepoint 2013 如何将文件上传到sharepoint文档库 - How to upload file to sharepoint document library 如何将文件上传到Sharepoint中的文档库? - How to upload a file to a document library in sharepoint? 使用CSOM打开和读取位于SharePoint文档库中的文本文件 - Open and Read a text file Located in a SharePoint Document Library using CSOM
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM