高分求将当前应用程序的目录装入到treeview中!
如何将当前web程序的装入到treeview中呢?在ms的应用程序安全配置中,有代码,不过,看不太明白。
代码如下:
protected override void OnInit(EventArgs e) {
base.OnInit(e);
if(!IsPostBack) {
// Note: treenodes persist when added in Init, before loadViewState
TreeNode n = new TreeNode(GetDirectory( " "), " ");
tv.Nodes.Add(n);
n.Selected = true;
String CurrentPath= " ";
String ApplicationPath= " ";
if (String.IsNullOrEmpty(CurrentPath)) {
CurrentPath = ApplicationPath;
}
PopulateChildren(n, CurrentPath);
}
}
private void PopulateChildren(TreeNode parent, string selectNodeValue) {
if (parent.ChildNodes.Count == 0) {
VirtualDirectory vdir = GetVirtualDirectory(parent.Value);
foreach (VirtualDirectory childVdir in vdir.Directories) {
string childValue = parent.Value + "/ " + childVdir.Name;
TreeNode newNode = new TreeNode(childVdir.Name, childValue);
if (selectNodeValue != null && childValue == selectNodeValue) {
//newNode.Selected = true;
newNode.SelectAction = TreeNodeSelectAction.Select;
}
parent.ChildNodes.Add(newNode);
}
}
}
其中那个GetVirtualDirectory完全不知道是什么?有些变量也不知道如何处理。有没有高手能给出具体的代码呢?说明一下,谢谢。
------解决方案--------------------找一下,GetVirtualDirectory应该是在代码中的某个方法吧
参考
http://aspnet.4guysfromrolla.com/articles/083006-1.aspx
------解决方案--------------------再提供一个
含演示和源代码下载
http://aspalliance.com/shark/articl