Downloading Wsp from SharePoint Central Admin

Using C#:

protected void btnDownloadWSP_Click(object sender, EventArgs e)
        {
            SPSolutionCollection allSolutions = SPFarm.Local.Solutions;
            foreach (SPSolution mySolution in allSolutions)
            {
                SPPersistedFile myWSP = mySolution.SolutionFile;
                if (myWSP.Name == "Sample.wsp")
                {
                    myWSP.SaveAs("c:\\Export All Solutions\\" + mySolution.Name);
                }
            }
        }

Here the SPSolutionCollection , SPPersistedFile classes are referred from   Microsoft.SharePoint.Administration namespace.

PowerShell:

$myFarm = Get-SPFarm
$myWSP = $myFarm.Solutions.Item("sample.wsp").SolutionFile
$ myWSP.SaveAs("c:\Export all\ Sample.wsp")

Comments

Popular posts from this blog

IRM and the Object Model

This content database has a schema version which is not supported in this farm

Activate and Deactivate Feature through PowerShell