Enable Sync to SharePoint Workspace using SharePoint Object Model:
- Open Visual Studio 2010.
- Go to File => New => Project.
- Select Console Application template from the installed templates.
- Enter the Name and Click on Ok.
- Add the following Reference.
Microsoft.SharePoint.dll - Add the following Namespace.
Using Microsoft.SharePoint;
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://demoshare:6969/sites/"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList("History");
if (list != null)
{
//Enable Sync to SharePoint Workspace
list.ExcludeFromOfflineClient = false;
//To Disable Sync to SharePoint Workspace => list.ExcludeFromOfflineClient = true;
list.Update();
Console.WriteLine("Sync to SharePoint Workspace is Enabled");
}
else
{
Console.WriteLine(list.Title + " does not exists in the site");
}
Console.ReadLine();
}
}
}
- Build the solution.
- Hit F5.
enabled sync to workspace button.