Home > Blogs > Blog Post

Code Sample : How to programmatically download all solutions (WSPs) in SharePoint

by Mark Jones | Dec 27, 2011

Once a solution has been added to SharePoint, then there's no apparent way to download it. Using the SharePoint object model we can easily download a wsp using the 'SaveAs' method. 

The C# code below illustrates how to download all of the solutions in the farm with just a few lines.

SPSolutionCollection solutionCollection = SPFarm.Local.Solutions;
 
foreach (SPSolution solution in solutionCollection)
{
    SPPersistedFile wsp = solution.SolutionFile;
 
        SaveWSP(wsp);
}
 
 
private void SaveWSP(SPPersistedFile wsp)
{
 if (wsp != null)
        {
 
 string fileName = Path.Combine(
 @"c:\temp\wspdownloads", 
                          wsp.Name);       
 
 if (System.IO.File.Exists(fileName))
            System.IO.File.Delete(fileName);
 
        wsp.SaveAs(fileName);
 
}

Compliance using DocRead

DocRead logoDocRead for SharePoint can help you manage policy compliance by:

  • Targeting documents or policies at specific groups of users
  • Allowing a specific amount of time for users to confirm agreement 
  • Sending email reminders when policy compliance is overdue
  • Users self-certify that they have read and fully understood the policy details
  • Securely storing records of confirmed policy acceptance
  • Monitoring the user acceptance of policies via a reporting suite
  • Providing detailed reading reports and statistics
  • Report drill through to show who has not accepted the policy
  • Automatically sending historic compliance tasks and policies to new users when they are added to a group
  • Bringing policy compliance requests immediately to users attention when they log on

DocRead is simple to install and configure. It seamlessly integrates with SharePoint and can be added to any existing SharePoint site.

To find out more, visit the DocRead product site.


blog comments powered by Disqus