Dim NodesThatMatch As New List(Of TreeNode) Private Function SearchTheTreeView(ByVal TV As TreeView, ByVal TextToFind As String) As TreeNode ' Empty previous NodesThatMatch.Clear() ' Keep calling RecursiveSearch For Each TN As TreeNode In TV.Nodes If TN.Text = TextToFind Then NodesThatMatch.Add(TN) End If RecursiveSearch(TN, TextToFind) Next If NodesThatMatch.Count > 0 Then Return NodesThatMatch(0) Else Return Nothing End If End Function Private Sub RecursiveSearch(ByVal treeNode As TreeNode, ByVal TextToFind As String) ' Keep calling the test recursively. For Each TN As TreeNode In treeNode.Nodes If TN.Text = TextToFind Then NodesThatMatch.Add(TN) End If RecursiveSearch(TN, TextToFind) Next End Sub Dim GoPlaceHolder As String = "" Private Sub btnexpand_Click(sender As Object, e As EventArgs) Handles btnexpand.Click If btnexpand.Text = CStr("CollapseAll") Then btnexpand.Text = "ExpandAll" Else btnexpand.Text = CStr("CollapseAll") End If If btnexpand.Text = "CollapseAll" Then explorer_tree.ExpandAll() If btnexpand.Text = "ExpandAll" Then explorer_tree.CollapseAll() End Sub Private Sub btnsavetxt_Click(sender As Object, e As EventArgs) Handles btnsavetxt.Click My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\snippettree_data\home\" + Txtenterpath.Text, hometxt.Text, False) End Sub Private Sub btnnewfolder_Click(sender As Object, e As EventArgs) Handles btnnewfolder.Click Dim di As DirectoryInfo Dim plus As String = Txtenterpath.Text If plus.Length > 1 Then di = New DirectoryInfo(home + "\" + plus) Else di = New DirectoryInfo(home) End If Dim sd As DirectoryInfo = di.CreateSubdirectory(Txtfoldername.Text) If Not Me.explorer_tree.SelectedNode Is Nothing Then Me.explorer_tree.SelectedNode.Collapse() Me.explorer_tree.SelectedNode.Expand() Else Dim Pname As String = sd.ToString Dim names() As String = Pname.Split("\") Dim count As Integer = names.Count - 1 For z As Integer = 0 To count btngo.PerformClick() explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, names(z)) Next End If End Sub Private Sub btnBinfolder_Click(sender As Object, e As EventArgs) Handles btnbinfolder.Click Dim snode2 As TreeNode = Me.explorer_tree.SelectedNode Dim vCurrentPath As String = GetFullPathForTreeNode(snode2) Dim Extension As String = Path.GetExtension(vCurrentPath) If Not Extension = ".txt" Or Extension = ".snippet" Then My.Computer.FileSystem.DeleteDirectory(Application.StartupPath + "\snippettree_data\home\" + Txtenterpath.Text, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) End If Dim parentf As String = dirictoryparentname1(vCurrentPath) Txtenterpath.Text = parentf explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, parentf) If Not Me.explorer_tree.SelectedNode Is Nothing Then Me.explorer_tree.SelectedNode.Collapse() Me.explorer_tree.SelectedNode.Expand() Else Dim Pname As String = parentf Dim names() As String = Pname.Split("\") Dim count As Integer = names.Count - 1 For z As Integer = 0 To count If GoPlaceHolder.Length > 0 Then gohome(home + "\" + GoPlaceHolder) Else gohome(home) End If explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, names(z)) Next End If End Sub Private Sub btnnewfile_Click(sender As Object, e As EventArgs) Handles btnnewfile.Click Dim str As String = Txtenterpath.Text If str.Contains(".txt") = False Then ' Suedo Code You Have A Parent If Txtenterpath.Text.Length > 0 Then Dim chosentxtname As String = txtfilename.Text Dim path As String = "" path = home & "\" & Txtenterpath.Text & "\" & chosentxtname & ".txt" Dim sw As StreamWriter = File.CreateText(path) ' Create a file to write to. sw.WriteLine("Hello") sw.Flush() sw.Close() ' Suedo Code Refresh The Home Loction NOW UPDATE Select Files If GoPlaceHolder.Length > 0 Then gohome(home + "\" + GoPlaceHolder) Dim fullname As String = Txtenterpath.Text & "\" & chosentxtname & ".txt" Dim names2() As String = fullname.Split("\") Dim count As Integer = names2.Count - 1 Dim fullnameGOPlaceHolder As String = GoPlaceHolder Dim namesGo() As String = fullnameGOPlaceHolder.Split("\") Dim countGo As Integer = namesGo.Count - 1 For z As Integer = 0 To count If z > countGo Then If Not z = count Then explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, names2(z)) Me.explorer_tree.SelectedNode.Expand() Else explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, names2(z)) End If End If Next Else gohome(home) Dim fullname As String = Txtenterpath.Text & "\" & chosentxtname & ".txt" Dim names2() As String = fullname.Split("\") Dim count As Integer = names2.Count - 1 For z As Integer = 0 To count If Not z = count Then explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, names2(z)) Me.explorer_tree.SelectedNode.Expand() Else explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, names2(z)) End If Next End If Else Dim chosentxtname As String = txtfilename.Text Dim path As String = "" path = home & "\" & chosentxtname & ".txt" Dim sw As StreamWriter = File.CreateText(path) ' Create a file to write to. sw.WriteLine("Hello") sw.Flush() sw.Close() gohome(home) explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, chosentxtname & ".txt") End If Else MsgBox("Can Not Create On Txt File") End If End Sub Private Sub BtnBack_Click(sender As Object, e As EventArgs) Handles BtnBack.Click If Not Me.explorer_tree.SelectedNode Is Nothing Then Dim snode2 As TreeNode = Me.explorer_tree.SelectedNode Dim vCurrentPath As String = GetFullPathForTreeNode(snode2) Dim newCurrentDirectory As DirectoryInfo = New DirectoryInfo(vCurrentPath) Dim HoldString As String = newCurrentDirectory.Parent.FullName Dim name1 As String = dirictoryname1(HoldString) explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, name1) Else MsgBox("Selected ?..") End If End Sub Private Sub Btnfiledel_Click_1(sender As Object, e As EventArgs) Handles Btnfiledel.Click Dim snode2 As TreeNode = Me.explorer_tree.SelectedNode Dim vCurrentPath As String = GetFullPathForTreeNode(snode2) Dim parentf As String = dirictoryparentname1(vCurrentPath) Dim placeholder As String = Txtenterpath.Text explorer_tree.SelectedNode = SearchTheTreeView(explorer_tree, parentf) My.Computer.FileSystem.DeleteFile(home + "\" + placeholder, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.SendToRecycleBin) If Not Me.explorer_tree.SelectedNode Is Nothing Then Me.explorer_tree.SelectedNode.Collapse() Me.explorer_tree.SelectedNode.Expand() Else Txtenterpath.Text = GoPlaceHolder hometxt.Clear() Dim vCurrentFolder As String = Application.StartupPath + "\snippettree_data\home\" + GoPlaceHolder Dim Extension As String = Path.GetExtension(Txtenterpath.Text) explorer_tree.BeginUpdate() explorer_tree.Nodes.Clear() FillExplorerTree(vCurrentFolder, Nothing) explorer_tree.EndUpdate() End If End Sub