Hi..

I am populating a treeview in form1 based on the checkeditems in checkedlistbox which is in form2 but am unable to list the subfolders and files of the checked folder..

Can anyone please help me????

Thanks..

I have achieved the above requirement as follows:-

    private void ListDirectory(TreeView treeView, string path)
    {
        treeView.Nodes.Clear();
        var rootDirectoryInfo = new DirectoryInfo(path);
        treeView.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo));
    }

    private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo)
    {
        var directoryNode = new TreeNode(directoryInfo.Name);
        foreach (var directory in directoryInfo.GetDirectories())
            directoryNode.Nodes.Add(CreateDirectoryNode(directory));
        foreach (var file in directoryInfo.GetFiles())
            directoryNode.Nodes.Add(new TreeNode(file.Name));
        return directoryNode;
    }
private void button1_Click(object sender, EventArgs e)
    {

        //string directory = opt.checkedListBox1.CheckedItems.ToString();
        foreach (var obj in opt.checkedListBox1.CheckedItems)
        {
            ListDirectory(treeView1, "E:\\mails\\" + obj);
            treeView1.ExpandAll();
        }

    }

But am unable to loop it for all checked folders,please guide me where am going wrong??