Thursday, January 3, 2013

Reading a SharePoint Site title Using a console App

File | New | Project |  Visual C# |  .Net Frame Work 3.5  | Console Application
 
Give a Name there:  | Choose Location |  Click on Ok.
 
1. Add reference : Microsoft.SharePoint.dll
      from the location:
            c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.dll
 
2.  Right Click on Console Application Project |
From Application |           Target Framework   | .Net Framework 3.5 
             Build | Target Plat from | Either X64 or Any Cpu  | Save the changes
 
Add u r reference :
using Microsoft.SharePoint.dll;


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            using( SPSite  spSite = new SPSite("http://sp2010") )
            {
                using (SPWeb spWeb = spSite.RootWeb)
                {
                    Console.Write(spWeb.Title);
                    Console.ReadLine();
                }
            }
        }
    }
}


 

No comments:

Post a Comment