string siteUserName="nam",_siteurl="http://sharepoint.com",_sitepassword ="pass@word1";
ClientContext clientContext = new ClientContext(_siteurl);
clientContext.AuthenticationMode =ClientAuthenticationMode.Default;
clientContext.Credentials = new System.Net.NetworkCredential(_siteUserName, _sitepassword, _domainName); Web oweb = clientContext.Web;
SharePointclientObj.ListCollection lists = oweb.Lists;
clientContext.Load(lists);
clientContext.ExecuteQuery();
var existingLists = clientContext.LoadQuery(lists.Where(list => list.Title == listname));
clientContext.ExecuteQuery();
var existingList = existingLists.FirstOrDefault();
if (existingList == null)
{
SharePointclientObj.ListCreationInformation lci = new SharePointclientObj.ListCreationInformation();
lci.Description ="Test";
lci.Title = "Test";
lci.TemplateType = 101;
SharePointclientObj.List newLib = clientContext.Web.Lists.Add(lci);
clientContext.Load(newLib);
clientContext.ExecuteQuery();
}
ClientContext clientContext = new ClientContext(_siteurl);
clientContext.AuthenticationMode =ClientAuthenticationMode.Default;
clientContext.Credentials = new System.Net.NetworkCredential(_siteUserName, _sitepassword, _domainName); Web oweb = clientContext.Web;
SharePointclientObj.ListCollection lists = oweb.Lists;
clientContext.Load(lists);
clientContext.ExecuteQuery();
var existingLists = clientContext.LoadQuery(lists.Where(list => list.Title == listname));
clientContext.ExecuteQuery();
var existingList = existingLists.FirstOrDefault();
if (existingList == null)
{
SharePointclientObj.ListCreationInformation lci = new SharePointclientObj.ListCreationInformation();
lci.Description ="Test";
lci.Title = "Test";
lci.TemplateType = 101;
SharePointclientObj.List newLib = clientContext.Web.Lists.Add(lci);
clientContext.Load(newLib);
clientContext.ExecuteQuery();
}
No comments:
Post a Comment