遍历当前目录下的所有文件夹和文件
/// <summary>
/// 遍历当前目录下的所有文件夹和文件
/// 搜索当前目录下的所有文件夹,添加到TreeView节点中递归遍历当前目录
/// </summary>
/// <param name="node">父节点</param>
/// <param name="path">目录路径</param>
private void GetDirectory(TreeNode node,string path)
{
string[] Directorys = Directory.GetDirectories(path);
foreach (string directory in Directorys)
{
string directoryName = DirectoryName(directory);
TreeNode childTreeNode = new TreeNode(directoryName);
node.Nodes.Add(childTreeNode);
GetDirectory(childTreeNode,directory);
}
}