In this post I will explain how to use your SharePoint app as module element to copy files to particular location in the Host SharePoint site.

  1. Create new Application

  2. You will find that an application project has been created for you
  3. Go to  the App project properties
  4. For the property "Handle App Installed" and "Handle App Uninstalling" enable both of them

  5. Visual studio will confirm creation of an web project 
  6. After the new web application project has been created place all your files in the web application In my case I placed all the files under PageLayout folder
  7. In the  AppEventReceiver.svc you can find that a method has been created for you 
  8. In this method we will add the code to handle adding files as the application been installed and removing files as the application uninstalled
  9. When Application installed it copies all the directories and the files within the "PageLayout" folder to the master page library recursively
  10. You can download the Full source code from here