簡體   English   中英

如何在 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");

        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM