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. What should I do in this situation?
Asked
Active
Viewed 60 times
1 Answers
1
Deploy to an existing library and then calling MoveTo in event receiver.
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");
}

Lee
- 5,305
- 1
- 6
- 12
-
What document library existed every where? I mean something like shared document, or site assets or ... or I can ask: Where is the common place to copy and use files and resource to use in your SharePoint solution? – hossein hashemian Nov 02 '19 at 07:05