Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void Add(string path, TreeNode node)
- {
- var childNode = new TreeNode {Text = path};
- node.Nodes.Add(childNode);
- try
- {
- foreach (var item in Directory.GetDirectories(path))
- {
- Add(item, childNode);
- }
- }
- catch
- { }
- }
- private void tvCatalog_BeforeExpand(object sender, TreeViewCancelEventArgs e)
- {
- try
- {
- foreach (var file in Directory.GetFiles(e.Node.Text))
- {
- e.Node.Nodes.Add(file);
- }
- if (e.Node.NextNode == null) return;
- {
- foreach (TreeNode node in e.Node.Nodes)
- {
- if (!Directory.Exists(node.Text)) continue;
- foreach (var file in Directory.GetFiles(node.Text))
- {
- node.Nodes.Add(file);
- }
- }
- }
- }
- catch
- { }
- }
- private void setdirs_Click(object sender, EventArgs e)
- {
- var disks = DriveInfo.GetDrives();
- var parentNode = new TreeNode();
- parentNode = tvCatalog.Nodes[0];
- foreach (var info in disks)
- {
- Add(info.ToString(), parentNode);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement