我这有一段C#代码,各位大侠帮帮我,解释一下语句八

来源:百度知道 编辑:UC知道 时间:2024/05/27 02:43:05
我这有一段C#代码,各位大侠帮帮我,解释一下语句八
由于我是初学者,所以希望大侠们解释得详细些哈

partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
if (!Directory.Exists("E:\\FOX"))
{
Directory.CreateDirectory("E:\\FOX");
}
PopulateTreeView();

}

private void Form1_Load(object sender, EventArgs e)
{
treeView1.ExpandAll();
}

private void GetDirectories(DirectoryInfo[] subDirs,
TreeNode nodeToAddTo)
{

TreeNode aNode;
DirectoryInfo[] subSubDirs;
foreach (DirectoryInfo subDir in subDirs)
{
aNode = new TreeNode(subDir.Name, 0, 0);
aNode.Tag = subDir;
subSubDirs = subDir

partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
if (!Directory.Exists("E:\\FOX")) //判断是否存在这个目录
{
Directory.CreateDirectory("E:\\FOX"); //如果不存在则创建这个目录
}
PopulateTreeView(); //调用这个函数

}

private void Form1_Load(object sender, EventArgs e)
{
treeView1.ExpandAll(); //把树所有节点都展开
}

//这个函数获取目录下的目录,组织成树
private void GetDirectories(DirectoryInfo[] subDirs,
TreeNode nodeToAddTo)
{

TreeNode aNode;
DirectoryInfo[] subSubDirs;
foreach (DirectoryInfo subDir in subDirs)
{
aNode = new TreeNode(subDir.Name, 0, 0);
aNode.Tag = subDir;
subSubDirs = subDir.GetDirectories();
if (subSubDirs.Length != 0)
{
GetDirectories(subSubDirs, aNode);
}
nodeToAddTo.Nodes.Add(aNode);
}

//foreach (FileInfo f in info.GetFile