Some times you need to download the solution file from SharePoint Farm. SharePoint user interface does not provide any functionality to achieve it . Don’t worry, you can extract the solution file from SharePoint Farm by using object model. Here is a simple function to extract your target solution file from SharePoint.
2 | /// Downloads the solution file from SharePoint Farm. |
4 | /// <param name="targetSolutionName">Name of the target solution.</param> |
5 | /// <param name="pathToSave">The path to save.</param> |
6 | private static void DownloadSolutionFile( string targetSolutionName, string pathToSave) |
8 | if (!String.IsNullOrEmpty(targetSolutionName) && !String.IsNullOrEmpty(pathToSave)) |
11 | var solution = (from s in SPFarm.Local.Solutions where s.Name == targetSolutionName select s).FirstOrDefault(); |
16 | SPPersistedFile solutionFile = solution.SolutionFile; |
17 | solutionFile.SaveAs(pathToSave + solutionFile.Name); |