Get a WSP solution file out of a SharePoint 2007 Farm
Build the following form with the the following code behind.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint.Administration;
namespace GET_WSP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
SPSolutionCollection solutions = SPFarm.Local.Solutions;
foreach (SPSolution solution in solutions)
{
SPPersistedFile wspFile = solution.SolutionFile;
SolutionCollectionListBox.Items.Add(solution.Name);
}
}
private void button1_Click(object sender, EventArgs e)
{
string FileLocation = FileLoc_textBox.Text;
SPSolutionCollection solutions = SPFarm.Local.Solutions;
System.Windows.Forms.ListBox.SelectedObjectCollection SelectedSolutions = SolutionCollectionListBox.SelectedItems;
foreach (SPSolution solution in solutions)
{
if (SolutionCollectionListBox.SelectedItems.Contains(solution.Name)||GetAllWSPs.Checked)
{
SPPersistedFile wspFile = solution.SolutionFile;
wspFile.SaveAs(FileLocation + solution.Name);
}
}
}
}
}
Comments
Post a Comment