在线跪求高手教小弟使用treeView控件 请高手告诉小弟,用treeView控件如何绑定c盘下windows文件夹中system32文件夹中的所有内容!?脑袋转得太慢,实在想不出来了!希望大侠用最简单的方法告诉小弟! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { string sPath = @"E:\Downloads"; InitTree(sPath , this.TreeView1.Nodes); } } private void InitTree(string sPath ,TreeNodeCollection tnCollection) { if(sPath != "") sPath += @"\"; DirectoryInfo info = new DirectoryInfo(sPath); DirectoryInfo[] folders = info.GetDirectories(); foreach(DirectoryInfo dir in folders) { TreeNode tn = new TreeNode(); tn.Text = dir.Name; tnCollection.Add(tn); InitTree(sPath + tn.Text , tnCollection[tnCollection.Count -1].Nodes); } } 读取文件夹时,需要有可读的权限.如果你把路径改为SYSTEM32时,可能某些文件读取不到(会出错). 感谢高手!可惜有个文件夹读不出来C:\WINDOWS\system32\config\systemprofile\ systemprofile你在这个文件的安全权限中,添加个EVERYONE的可读权限 DIV 跟着移动问题 求高手赐教!!!!!! 数据库的增删改方法报错 .NET 定时器 固定时间执行插入数据 这样的上传图片代码应该怎么用。 传值问题 SQL小问题。请大家帮帮我。 菜鸟问个asp.net操作sql输出xml语句的问题 关于DataGrid两个问题 完蛋了,怎么不能编译了,出现如下问题:Could not execute CVTRES.EXE 到底--浏览器端的技术还重不重要? 问两个关于数据库的菜问题 一个扩展GridView控件,简单实用~
{
if(!IsPostBack)
{
string sPath = @"E:\Downloads";
InitTree(sPath , this.TreeView1.Nodes);
}
} private void InitTree(string sPath ,TreeNodeCollection tnCollection)
{
if(sPath != "") sPath += @"\";
DirectoryInfo info = new DirectoryInfo(sPath);
DirectoryInfo[] folders = info.GetDirectories();
foreach(DirectoryInfo dir in folders)
{
TreeNode tn = new TreeNode();
tn.Text = dir.Name; tnCollection.Add(tn); InitTree(sPath + tn.Text , tnCollection[tnCollection.Count -1].Nodes);
}
}
如果你把路径改为SYSTEM32时,可能某些文件读取不到(会出错).
可惜有个文件夹读不出来
C:\WINDOWS\system32\config\systemprofile\