为什么用本地硬盘内容填充tvwSource,要先清除所有节点? 为什么用本地硬盘内容填充tvwSource,要先清除所有节点?tvw.Nodes.Clear(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 以下是源代码private void FillDirectoryTree(TreeView tvw, bool isSource) { tvw.Nodes.Clear(); //问题就是这,为什么要先清除结点内容呢,不是还没填充吗? string[] strDrives = Environment.GetLogicalDrives(); foreach (string rootDirectoryName in strDrives) { try { DirectoryInfo dir = new DirectoryInfo(rootDirectoryName); dir.GetDirectories(); TreeNode ndRoot = new TreeNode(rootDirectoryName); tvw.Nodes.Add(ndRoot); if (isSource) { GetSubDirectoryNodes(ndRoot, ndRoot.Text, true, 1); } else { GetSubdirectoryNodes( ndRoot, ndRoot.Text, false, 1 ); } } catch { } Application.DoEvents(); } } C# 类型转换 关于系统开销的一些问题 vb调用c#做的com问题 如何用C#解压rar文件 怎样调用VB写的DLL亚!! 金油条网页正文提取开发组件1.0发布 radiobutton点击赋值问题 高分求:毕业设计项目(要求比较有趣的,有创意的,小型的)请大家帮忙 c#的开发平台除了.net还有哪些?? 请算法达人帮看看,下面的代码可否优化以提高执行效率? TCP传输c#对数字转换成字节需要手动改为大端模式,如果对字符串呢? 求助怎样终止一个事件?
{
tvw.Nodes.Clear(); //问题就是这,为什么要先清除结点内容呢,不是还没填充吗?
string[] strDrives = Environment.GetLogicalDrives();
foreach (string rootDirectoryName in strDrives)
{
try
{
DirectoryInfo dir =
new DirectoryInfo(rootDirectoryName);
dir.GetDirectories();
TreeNode ndRoot = new TreeNode(rootDirectoryName);
tvw.Nodes.Add(ndRoot);
if (isSource)
{
GetSubDirectoryNodes(ndRoot, ndRoot.Text, true, 1);
}
else
{
GetSubdirectoryNodes(
ndRoot, ndRoot.Text, false, 1
);
}
}
catch
{
}
Application.DoEvents();
}
}