I need to create one treeview and to have there all of my directories and files from one path.
I cant compile this code. The problem is on this line : mnodedirectory.nodes.add(mfilesnode)
' get the directory representing this node
Dim mnodedirectory As IO.DirectoryInfo
mnodedirectory = New IO.DirectoryInfo(e.Node.Tag.ToString)
' add each subdirectory from the file system to the expanding node as a child node
For Each mdirectory As IO.DirectoryInfo In mnodedirectory.GetDirectories
' declare a child treenode for the next subdirectory
Dim mdirectorynode As New TreeNode
' store the full path to this directory in the child treenode's tag property
mdirectorynode.Tag = mdirectory.FullName
' set the child treenodes's display text
mdirectorynode.Text = mdirectory.Name
' add a dummy treenode to this child treenode to make it expandable
mdirectorynode.Nodes.Add("*temp*")
' add this child treenode to the expanding treenode
e.Node.Nodes.Add(mdirectorynode)
Next
For Each mfile As IO.FileInfo In mnodedirectory.GetFiles
Dim mfilesnode As New TreeNode
mfilesnode.Tag = mfile.FullName
mfilesnode.Text = mfile.Name
mnodedirectory.nodes.add(mfilesnode)
Next
See Question&Answers more detail:os