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

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

我在模块中有一个文本文件,我需要将该文件复制到一个尚不存在的文档库中,它将在 featureActivated 中创建。这种情况怎么办?

部署到现有库,然后在事件接收器中调用 MoveTo。

示例演示:

<?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");

        }