private void FillTreeView()
{
documentLibraryStructureTreeView.Nodes.Clear();
ClientContext clientContext = new ClientContext("http://sp2013:10021/demo");
clientContext.Credentials = new System.Net.NetworkCredential("username", "password", "servername");
clientContext.Load(clientContext.Web.Lists);
clientContext.ExecuteQuery();
foreach (List list in clientContext.Web.Lists)
{
try
{
if (list.BaseType.ToString() == "DocumentLibrary" && !list.IsApplicationList && !list.Hidden && list.Title != "Form Templates" && list.Title != "Customized Reports" && list.Title != "Site Collection Documents" && list.Title != "Site Collection Images" && list.Title != "Images" && list.Title != "Style Library")
{
clientContext.Load(list);
clientContext.ExecuteQuery();
clientContext.Load(list.RootFolder);
clientContext.Load(list.RootFolder.Folders);
clientContext.ExecuteQuery();
documentLibraryStructureTreeView.ShowLines = true;
TreeNode LibraryNode = new TreeNode(list.Title);
documentLibraryStructureTreeView.Nodes.Add(LibraryNode);
Folder root = list.RootFolder;
FillTreeViewNodes(root, LibraryNode, clientContext);
}
}
catch
{
}
}
}
public void FillTreeViewNodes(Folder SubFolder, TreeNode MainNode, ClientContext clientcontext)
{
clientcontext.Load(SubFolder.Files);
clientcontext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.File Fol in SubFolder.Files)
{
TreeNode SubNode = new TreeNode(Path.ChangeExtension(Fol.Name,string.Empty));
MainNode.ChildNodes.Add(SubNode);
}
}
{
documentLibraryStructureTreeView.Nodes.Clear();
ClientContext clientContext = new ClientContext("http://sp2013:10021/demo");
clientContext.Credentials = new System.Net.NetworkCredential("username", "password", "servername");
clientContext.Load(clientContext.Web.Lists);
clientContext.ExecuteQuery();
foreach (List list in clientContext.Web.Lists)
{
try
{
if (list.BaseType.ToString() == "DocumentLibrary" && !list.IsApplicationList && !list.Hidden && list.Title != "Form Templates" && list.Title != "Customized Reports" && list.Title != "Site Collection Documents" && list.Title != "Site Collection Images" && list.Title != "Images" && list.Title != "Style Library")
{
clientContext.Load(list);
clientContext.ExecuteQuery();
clientContext.Load(list.RootFolder);
clientContext.Load(list.RootFolder.Folders);
clientContext.ExecuteQuery();
documentLibraryStructureTreeView.ShowLines = true;
TreeNode LibraryNode = new TreeNode(list.Title);
documentLibraryStructureTreeView.Nodes.Add(LibraryNode);
Folder root = list.RootFolder;
FillTreeViewNodes(root, LibraryNode, clientContext);
}
}
catch
{
}
}
}
public void FillTreeViewNodes(Folder SubFolder, TreeNode MainNode, ClientContext clientcontext)
{
clientcontext.Load(SubFolder.Files);
clientcontext.ExecuteQuery();
foreach (Microsoft.SharePoint.Client.File Fol in SubFolder.Files)
{
TreeNode SubNode = new TreeNode(Path.ChangeExtension(Fol.Name,string.Empty));
MainNode.ChildNodes.Add(SubNode);
}
}