从一个路径我Ahve阅读三个不同的文件夹并将该文件夹加载到C#中的树控件 [英] From A Path I Ahve To Read The Three Difrennt Folder And To Load That Folder To A Tree Control In C#

查看:57
本文介绍了从一个路径我Ahve阅读三个不同的文件夹并将该文件夹加载到C#中的树控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





在路径中假设我有n个文件和文件夹我必须阅读Specfic三个文件夹支持a,b,c和内容此文件夹并加载到三个控件,根节点在c#winform应用程序中固定为假设T。

hi

in a path suppose i have n number of file and folder i have to read the Specfic three folder suppase a,b,c and the content of this folder and load to three control with root node fixed as suppose T in c# winform application.

推荐答案

一些有用的链接 [ ^ ]。


试试这个样本..



Try this sample..

string folderLocation1 = @"D:\OLD Projects\BEData\BEData\Scripts";
           string folderLocation2 = @"D:\OLD Projects\BEData\BEData\Styles\css";
           string folderLocation3 = @"D:\OLD Projects\BEData\BEData\Images";

           treeView1.Nodes.Add("scripts");
           TreeNode[] tn1 = new DirectoryInfo(folderLocation1).GetFiles().Select(k => new TreeNode() { Text = (k.Name) }).ToArray();
           treeView1.Nodes[0].Nodes.AddRange(tn1);

           TreeNode[] tn2 = new DirectoryInfo(folderLocation2).GetFiles().Select(k => new TreeNode() { Text = (k.Name) }).ToArray();
           treeView1.Nodes.Add("csss");
           treeView1.Nodes[1].Nodes.AddRange(tn2);

           TreeNode[] tn3 = new DirectoryInfo(folderLocation3).GetFiles().Select(k => new TreeNode() { Text = (k.Name) }).ToArray();
           treeView1.Nodes.Add("images");
           treeView1.Nodes[2].Nodes.AddRange(tn3);


这篇关于从一个路径我Ahve阅读三个不同的文件夹并将该文件夹加载到C#中的树控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆