1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'http://ja.doukaku.org/
'http://ja.doukaku.org/102/投稿用
Imports System
Imports System.Windows.Forms

NameSpace どう書く_orgフォルダパス一覧のツリー構造への変換
    Class Program
        <STAThread> _
        Shared Sub Main(byval args() As String)
            Application.Run(new Form1())
        End Sub
    End Class

    class Form1:Inherits Form
        'treeView1
        Dim treeView1 As TreeView = New TreeView()

        '起動時引数でパス一覧のファイルを指定
        Dim pathListFilePath As String = System.Environment.GetCommandLineArgs()(1)

        Public Sub New()
            'treeView1
            treeView1.Parent = Me
            treeView1.Dock = DockStyle.Fill
        End Sub

        Private Sub Form1_Load(byval sender As object, byval e As EventArgs)handles Me.Load
            'ROOTNode
            Dim rootNode As TreeNode = New TreeNode("ROOT")
            treeView1.Nodes.Add(rootNode)

            For Each fullPath As String In System.IO.File.ReadAllLines(pathListFilePath)
                Dim addNode As TreeNode = rootNode
                For Each path As String In fullPath.Split(New char(){"\"c})
                    Dim flag As Boolean = True
                    For Each node As TreeNode in addNode.Nodes
                        If node.Text = path Then
                            addNode = node
                            flag = False
                        End If
                    Next
                    if flag Then
                        Dim newnode As TreeNode = New TreeNode(path)
                        addNode.Nodes.Add(newnode)
                        addNode = newnode
                    End If
                Next
            Next
            rootNode.ExpandAll()
        End Sub
    End Class
End NameSpace