SharePoint client Object model Add and delete operations to calendars, complete code
1 // instantiate a Web site, get context relationships 2 New ClientContext ("http://spweb");
1 // Identity Verification 2 New System.Net.NetworkCredential (" user name " " password "" Domain ");
1 // Get Action Object 2 Web web = c.web;
String Renyuan = "Zhangshan,lisi";
string[] Rilirenyuan = new string[] {};
Rilirenyuan = Renyuan. Split (', ');
//adding an action to a calendarListcreationinformation Listinfo =NULL; foreach(varIteminchRilirenyuan) {Listinfo=Newlistcreationinformation (); Listinfo.title=item; Listinfo.templatetype= (int) listtemplatetype.events; Listinfo.quicklaunchoption=Quicklaunchoptions.off; Web. Lists.add (Listinfo); C.executequery (); stringmsg ="http://spweb/_layouts/15/start.aspx#/Lists/"+ Item +"/calendar.aspx \ r \ n"; byte[] MyByte =System.Text.Encoding.UTF8.GetBytes (msg);//output log records using(FileStream fswrite =NewFileStream (@"D:\1.txt", Filemode.append)) {Fswrite.write (MyByte,0, mybyte.length); }; Console.WriteLine (item); }
// Delete operations on a calendar foreach (var in Rilirenyuan) { = web. Lists.getbytitle (item); Olist.deleteobject (); C.executequery (); " Delete " ); }
Calendar actions for the SharePoint client object model