Um Datein ein eigenes Icon zu verpassen hab ich es so gelöst oder gibt es da andere möglichkeiten.
VB.NET-Quellcode
- ShowTree("C:\...")
- Public Sub ShowTree(ByVal Path As String)
- If System.IO.Directory.Exists(Path) Then
- Dim nNode As New TreeNode(Path)
- TreeView1.Nodes.Add(nNode)
- Me.FillTreeNode(nNode)
- End If
- End Sub
- Private Sub FillTreeNode(ByVal dNode As TreeNode)
- Try
- Dim d As New DirectoryInfo(dNode.FullPath)
- For Each di As DirectoryInfo In d.GetDirectories
- Dim nNode As New TreeNode(di.Name, 0, 0)
- dNode.Nodes.Add(nNode)
- FillTreeNode(nNode)
- Next
- For Each fi As FileInfo In d.GetFiles
- Dim fNode As New TreeNode
- fNode = New TreeNode(fi.Name, 1, 1)
- If Path.GetExtension(fi.FullName) = ".sln" Then
- fNode = New TreeNode(fi.Name, 2, 2)
- End If
- If Path.GetExtension(fi.FullName) = ".exe" Then
- fNode = New TreeNode(fi.Name, 3, 3)
- End If
- dNode.Nodes.Add(fNode)
- Next
- Catch : End Try
- End Sub