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.
/// <summary> /// Downloads the solution file from SharePoint Farm. /// </summary> /// <param name="targetSolutionName">Name of the target solution.</param> /// <param name="pathToSave">The path to save.</param> private static void DownloadSolutionFile(string targetSolutionName, string pathToSave) { if (!String.IsNullOrEmpty(targetSolutionName) && !String.IsNullOrEmpty(pathToSave)) { //Search for target solution var solution = (from s in SPFarm.Local.Solutions where s.Name == targetSolutionName select s).FirstOrDefault(); if (solution != null) { //target solution found, extract the solution file and save it SPPersistedFile solutionFile = solution.SolutionFile; solutionFile.SaveAs(pathToSave + solutionFile.Name); } } }