日期:2014-05-17 浏览次数:20537 次
<div>这是前台代码
<asp:TreeView ID="Tree" runat="server" DataSourceID="XDS" ShowLines="True" OnSelectedNodeChanged="Tree_SelectedNodeChanged" OnTreeNodeCheckChanged="Tree_TreeNodeCheckChanged" OnTreeNodeDataBound="Tree_TreeNodeDataBound" Target="_self">
</asp:TreeView>
<asp:XmlDataSource ID="XDS" runat="server"></asp:XmlDataSource>
</div>
int zishu(string s1, string s2)
{
int i = -1, x = -1;
do
{
i = s1.IndexOf(s2, ++i);
x++;
} while (i != -1);
return x;
}
void run()
{
string path = Server.MapPath("/");
string[] s = Directory.GetDirectories(path, "*.*", SearchOption.AllDirectories);
for (int i = 0; i < s.Length; i++)
{
s[i] = s[i].Substring(path.Length);
s[i] = s[i].Replace("\\", "/");
}
XmlDocument doc = new XmlDocument();
XmlElement xe = doc.CreateElement("根节点");
doc.AppendChild(xe);
int max = 0;
foreach (string str in s)
{
if (zishu(str, "/") > max)
{
max = zishu(str, "/");