You have to reference following two dll file in your project.
You can find this file at "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell"
example.
using System;
using System.Windows.Forms;
using Microsoft.SharePoint.Client;
using System.Security;
namespace CAML_CSOMDemo
{
public partial class Form1 : System.Windows.Forms.Form
{
public Form1()
{
InitializeComponent();
}
private void bntExecute_Click(object sender, EventArgs e)
{
using (ClientContext ctx = new ClientContext("https://contoso.sharepoint.com/"))
{
string uname = "myemail@contoso.com";
SecureString upwd = new System.Net.NetworkCredential("", "P@ssw0rd").SecurePassword;
ctx.Credentials = new SharePointOnlineCredentials(uname,upwd);
Web myWeb = ctx.Web;
List productsList = myWeb.Lists.GetByTitle("CSOM_TestList");
ctx.Load(myWeb);
ctx.ExecuteQuery();
MessageBox.Show(myWeb.Title);
}
}
- Microsoft.SharePoint.Client.dll
- Microsoft.SharePoint.Client.Runtime.dll
You can find this file at "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell"
example.
using System;
using System.Windows.Forms;
using Microsoft.SharePoint.Client;
using System.Security;
namespace CAML_CSOMDemo
{
public partial class Form1 : System.Windows.Forms.Form
{
public Form1()
{
InitializeComponent();
}
private void bntExecute_Click(object sender, EventArgs e)
{
using (ClientContext ctx = new ClientContext("https://contoso.sharepoint.com/"))
{
string uname = "myemail@contoso.com";
SecureString upwd = new System.Net.NetworkCredential("", "P@ssw0rd").SecurePassword;
ctx.Credentials = new SharePointOnlineCredentials(uname,upwd);
Web myWeb = ctx.Web;
List productsList = myWeb.Lists.GetByTitle("CSOM_TestList");
ctx.Load(myWeb);
ctx.ExecuteQuery();
MessageBox.Show(myWeb.Title);
}
}
}// end of class
}// end of namespace
No comments:
Post a Comment
Your feedback is always appreciated. I will try to reply to your queries as soon as time allows.Please don't spam,spam comments will be deleted upon reviews.