I need to deploy different images into picture library for different sub sites in a single feature, I mean I have five images, I need to deploy the first two image in the site collection, third image in subsite as well as last two images in another two subsites. I am not sure is this possible.I think we can achieve this by XML and c#. Please suggest me some best practices.

1 Answer 1


Don't do this by XML declarative code, but use a feature event receiver to implement anything you want with C# code:
With the feature ER code, you can easily leverage the server-side API to connect to the root site of the site collection (assuming the feature is site-scoped, i.e. site collection) and any sub-site you want (the clever approach being to create those sub-sites as well when the feature is activated, so you know their URL).
If you have an ElementFile as part of your feature, you can get access to it when the feature is deployed, from the ER code: simply get the properties.Definition.RootDirectory and build the complete path of the file you want to read. Then, use the simple and well-known API calls to upload the file wherever you want in SharePoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.