try
{
listView_DocumentList.Clear();
titleName = this.listView_TitleList.SelectedItems[0].Text;
string sitrUrl = textBox_URL.Text;//Sharepoint 2013 web service URL
Microsoft.SharePoint.Client.ClientContext clientContext = new Microsoft.SharePoint.Client.ClientContext(sitrUrl);
clientContext.Credentials = new NetworkCredential(textBox_ID.Text, textBox_PW.Text);//SharePoint2013 access ID and Password
Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle(titleName);//Sharepoint 2013 Library title
clientContext.Load(spList);
clientContext.ExecuteQuery();
if (spList != null && spList.ItemCount > 0)
{
Microsoft.SharePoint.Client.CamlQuery camlQuery = new Microsoft.SharePoint.Client.CamlQuery();
camlQuery.ViewXml = @"<View Scope='RecursiveAll'> <Query> <Where><Eq><FieldRef Name='FSObjType' /><Value Type='Integer'>0</Value></Eq></Where>
</Query> <ViewFields><FieldRef Name='FileLeafRef' /></ViewFields> </View>";
Microsoft.SharePoint.Client.ListItemCollection listItems = spList.GetItems(camlQuery);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
foreach (var item in listItems)
{
Add_ListViewItem_Document(Convert.ToString(item.FieldValues["ID"]), Convert.ToString(item.FieldValues["FileRef"]), Convert.ToString(item.FieldValues["FileLeafRef"]));
}
}
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
No comments:
Post a Comment