[英]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.