Search This Blog

Wednesday, December 3, 2014

How to Insert notepad data into CustomList In SharePoint 2010/ View Site Groups In SharePoint 2010

How to Insert notepad data into CustomList In SharePoint 2010

            SPWeb web = new SPSite("http://demo:500/").OpenWeb();
            SPList empList = web.Lists["Dept"];
            SPListItem item;
            StreamReader sr = new StreamReader("C:\\a.txt");
            while (sr.Peek() != -1)
            {
                string record = sr.ReadLine();
                string[] data=record.Split(' ');
                item=empList.Items.Add();
                item["Title"]=data[0];
                item["DeptName"]=data[1];
                item["DeptId"]=data[2];
                item.Update();
            }
In Notepad:
1    IT     10
2   Gov   20


View Site Groups In SharePoint 2010

using (SPSite siteCollection = new SPSite("http://hrweb"))
 {
   using (SPWeb site = siteCollection.OpenWeb())
     {
       // Print all groups name of site
       foreach (SPGroup group in site.Groups)
       {
          Console.WriteLine(group.Name);
        }
      Console.WriteLine("View All Site Groups");
 }
}

No comments:

Post a Comment