<%@ Idioma da página="C#" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" " http://www.w3.org/TR/xhtml11/DTD/xhtml11 .dtd ">
<script runat="server">
void Treeview1_TreeNodePopulate(objeto remetente, TreeNodeEventArgs e)
{
if (IsCallback)
se (e.Node.ChildNodes.Count == 0)
{
LoadChildNode(e.Node);
}
}
private void LoadChildNode (nó TreeNode)
{
Diretório DirectoryInfo;
diretório = novo DirectoryInfo(node.Value);
foreach (subDirectoryInfo em directory.GetDirectories())
{
TreeNode subNode = new TreeNode(sub.Nome);
subNode.Value = sub.NomeCompleto;
tentar
{
if (sub.GetDirectories().Length > 0 || sub.GetFiles().Length > 0)
{
subNode.SelectAction = TreeNodeSelectAction.SelectExpand;
subNode.PopulateOnDemand = verdadeiro;
subNode.NavigateUrl = "#";
}
}
pegar { subNode.ImageUrl = "WebResource.axd?a=s&r=TreeView_XP_Explorer_ParentNode.gif&t=632242003305625000"; }
node.ChildNodes.Add(subNode);
}
foreach (FileInfo fi em directory.GetFiles())
{
TreeNode subNode = new TreeNode(fi.Nome);
node.ChildNodes.Add(subNode);
}
}
</script>
<html xmlns=" http://www.w3.org/1999/xhtml " >
<head runat="servidor">
<title>Página sem título</title>
</head>
<body bgcolor="branco">
<form id="form1" runat="servidor">
<div>
<asp:treeview ID="Treeview1" runat="server" ImageSet="XPFileExplorer" AutoGenerateDataBindings="false" ExpandDepth=0
OnTreeNodePopulate="Treeview1_TreeNodePopulate"
>
<SelectedNodeStyle BackColor="#B5B5B5"></SelectedNodeStyle>
<Nós>
<asp:TreeNode Value="C:" Text="C:" PopulateOnDemand="true" SelectAction="Select" NavigateUrl="#" >
</asp:TreeNode>
</Nós>
<NodeStyle VerticalPadding="2" Font-Names="Tahoma" Font-Size="8pt" HorizontalPadding="2"
ForeColor="Preto"></NodeStyle>
<HoverNodeStyle Font-Underline="True" ForeColor="#6666AA"></HoverNodeStyle>
</asp:treeview>
</div>
</form>
</body>
</html>