Hello everyone,
I have a big dilemma. I am making a folder searcher, and if search term is found, then list all files in that folder. This is what I have:
If CheckBox1.Checked Then
For Each FOLDER As String In IO.Directory.GetDirectories(frmMain.SnippetsFolder)
If CheckBox3.Checked Then
If FOLDER.Replace(IO.Directory.GetParent(FOLDER).FullName, "").Contains(TextBox1.Text) Then
frmMain.TreeView1.Nodes.Add("Folder", My.Computer.FileSystem.GetName(FOLDER))
For Each File As String In IO.Directory.GetFiles(FOLDER, "*.cdbf")
Dim specFile As String = My.Computer.FileSystem.GetName(File)
Dim specIndex As Integer = specFile.LastIndexOf(".")
frmMain.TreeView1.Nodes(i).Nodes.Add("Item", specFile.Remove(specIndex), 1, 1)
Next
End If
Else
If FOLDER.Replace(IO.Directory.GetParent(FOLDER).FullName, "").ToLower.Contains(TextBox1.Text.ToLower) Then
frmMain.TreeView1.Nodes.Add("Folder", My.Computer.FileSystem.GetName(FOLDER))
For Each File As String In IO.Directory.GetFiles(FOLDER, "*.cdbf")
Dim specFile As String = My.Computer.FileSystem.GetName(File)
Dim specIndex As Integer = specFile.LastIndexOf(".")
frmMain.TreeView1.Nodes(i).Nodes.Add("Item", specFile.Remove(specIndex), 1, 1)
Next
i += 1
End If
End If
Next
End If
Unfortunately, I cannot fix this myself. I have stepped in, debugged and whatnot, I just can't find the issue.
The issue is this:
For example, I have an array of treenodes:
Internet
Windows
When I search "Win"
It will give me Windows, insert the files into that treenode. But it inserts another top-level "Windows" treenode, with NO files listed under it.
And if I have multiple top-level folders which fall under the search terms, then it gets even more stuffed up.
If anyone can help, then that would be awesome.
Regards,
iProgramIt
[
urgently has been removed]