1 |
6ba3e887
|
Gyusu
|
Imports System.IO
|
2 |
|
|
|
3 |
|
|
Public Class LoadXml
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
Dim first_start As Boolean = False
|
7 |
|
|
Dim folders_path As String
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
Private Sub Tree_XMLFiles_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterSelect
|
12 |
|
|
If first_start = False Then Exit Sub
|
13 |
|
|
Dim pa = e.Node.FullPath.ToString
|
14 |
|
|
|
15 |
|
|
printfilesfolders_here(pa, e.Node)
|
16 |
|
|
|
17 |
|
|
displayfiles(pa)
|
18 |
|
|
|
19 |
|
|
Dim coco As String = ""
|
20 |
|
|
coco = pa.ToString
|
21 |
|
|
coco = coco.Replace("\\", "\")
|
22 |
|
|
Me.Text = coco
|
23 |
|
|
folders_path = coco
|
24 |
|
|
End Sub
|
25 |
|
|
|
26 |
|
|
Sub printfilesfolders_here(ByVal path As String, ByRef itree As TreeNode)
|
27 |
|
|
|
28 |
|
|
Dim foldername As String
|
29 |
|
|
Dim filename As String
|
30 |
|
|
itree.Nodes.Clear()
|
31 |
|
|
On Error GoTo eee
|
32 |
|
|
For Each foldername In Directory.GetDirectories(path)
|
33 |
|
|
On Error GoTo eee
|
34 |
|
|
Dim jj = foldername.LastIndexOf("\")
|
35 |
|
|
Dim jj1 = foldername.Length - jj
|
36 |
|
|
Dim foldr = foldername.Substring((jj + 1), (jj1 - 1))
|
37 |
|
|
itree.Nodes.Add(foldr, foldr)
|
38 |
|
|
Next ' if you put this next at the end of procedure recursive will be done on first folder only
|
39 |
|
|
Exit Sub
|
40 |
|
|
eee:
|
41 |
|
|
End Sub
|
42 |
|
|
|
43 |
|
|
Sub displayfiles(ByVal path As String)
|
44 |
|
|
|
45 |
|
|
Dim lvItem As ListViewItem
|
46 |
|
|
ListView_File.Items.Clear()
|
47 |
|
|
Dim filename As String
|
48 |
|
|
On Error GoTo wwq
|
49 |
|
|
|
50 |
|
|
For Each filename In Directory.GetFiles(path)
|
51 |
|
|
On Error GoTo wwq
|
52 |
|
|
Dim jj_ = filename.LastIndexOf("\")
|
53 |
|
|
Dim jj1_ = filename.Length - jj_
|
54 |
|
|
Dim fil = filename.Substring((jj_ + 1), (jj1_ - 1))
|
55 |
|
|
If fil.Contains(".xml") Then
|
56 |
|
|
lvItem = ListView_File.Items.Add(filename, fil, 13) '2 5 7 work, 0 alos
|
57 |
|
|
Dim infoReader As System.IO.FileInfo
|
58 |
|
|
infoReader = My.Computer.FileSystem.GetFileInfo(filename)
|
59 |
|
|
lvItem.SubItems.AddRange(New String() {infoReader.LastWriteTime})
|
60 |
|
|
ListView_File.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent)
|
61 |
|
|
End If
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
Next
|
65 |
|
|
Exit Sub
|
66 |
|
|
wwq:
|
67 |
|
|
MsgBox(Err.Description)
|
68 |
|
|
End Sub
|
69 |
|
|
|
70 |
|
|
Private Sub Tree_XMLFiles_MouseMove(sender As Object, e As MouseEventArgs) Handles Tree_XMLFiles.MouseMove
|
71 |
|
|
first_start = True
|
72 |
|
|
End Sub
|
73 |
|
|
Private Sub LoadTree()
|
74 |
|
|
|
75 |
|
|
Dim i As Integer
|
76 |
|
|
Dim j() As String
|
77 |
|
|
j = Directory.GetLogicalDrives
|
78 |
|
|
For i = 0 To UBound(j)
|
79 |
|
|
|
80 |
|
|
Dim cdrive As System.IO.DriveInfo
|
81 |
|
|
cdrive = My.Computer.FileSystem.GetDriveInfo(j(i).ToString)
|
82 |
|
|
|
83 |
|
|
Select Case cdrive.DriveType
|
84 |
|
|
Case DriveType.Fixed
|
85 |
|
|
Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 3)
|
86 |
|
|
Case DriveType.CDRom
|
87 |
|
|
Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 11)
|
88 |
|
|
Case DriveType.Network
|
89 |
|
|
Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 5)
|
90 |
|
|
Case DriveType.Removable
|
91 |
|
|
Tree_XMLFiles.Nodes.Add(j(i), j(i).ToString, 12)
|
92 |
|
|
End Select
|
93 |
|
|
|
94 |
|
|
Next
|
95 |
|
|
End Sub
|
96 |
|
|
|
97 |
|
|
Private Sub SetUpListViewColumns()
|
98 |
|
|
' TODO: Add code to set up listview columns
|
99 |
|
|
ListView_File.Columns.Add(" Name ")
|
100 |
|
|
' ListView_File.Columns.Add(" Size ")
|
101 |
|
|
' ListView_File.Columns.Add(" Extension ")
|
102 |
|
|
ListView_File.Columns.Add(" Date Modified ")
|
103 |
|
|
SetView(View.Details)
|
104 |
|
|
End Sub
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
Private Sub SetView(ByVal View As System.Windows.Forms.View)
|
108 |
|
|
ListView_File.View = View.Details
|
109 |
|
|
End Sub
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
Private Sub InitXMLTree(ByVal sFolderPath As String)
|
114 |
|
|
Tree_XMLFiles.Nodes.Clear()
|
115 |
|
|
Dim oRootNode As TreeNode = Tree_XMLFiles.Nodes.Add("XML")
|
116 |
|
|
'.XML 만 로드
|
117 |
|
|
Dim sfileEntries As String() = Directory.GetFiles(sFolderPath, "*.xml")
|
118 |
|
|
' Process the list of files found in the directory.
|
119 |
|
|
Dim sfileName As String
|
120 |
|
|
For Each sfileName In sfileEntries
|
121 |
|
|
oRootNode.Nodes.Add(sfileName)
|
122 |
|
|
Next sfileName
|
123 |
|
|
oRootNode.ExpandAll()
|
124 |
|
|
End Sub
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
Private Sub Tree_XMLFiles_AfterCheck(sender As Object, e As TreeViewEventArgs) Handles Tree_XMLFiles.AfterCheck
|
128 |
|
|
If e.Node.Checked = True Then
|
129 |
|
|
For Each oNode As TreeNode In e.Node.Nodes
|
130 |
|
|
oNode.Checked = True
|
131 |
|
|
Next
|
132 |
|
|
Else
|
133 |
|
|
For Each oNode As TreeNode In e.Node.Nodes
|
134 |
|
|
oNode.Checked = False
|
135 |
|
|
Next
|
136 |
|
|
End If
|
137 |
|
|
End Sub
|
138 |
|
|
|
139 |
|
|
Private Sub LoadXml_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
140 |
|
|
SetUpListViewColumns()
|
141 |
|
|
LoadTree()
|
142 |
|
|
End Sub
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
Public ReadOnly Property GetCheckList() As ListView
|
146 |
|
|
Get
|
147 |
|
|
Return ListView_File
|
148 |
|
|
End Get
|
149 |
|
|
End Property
|
150 |
|
|
|
151 |
|
|
Private Sub Btn_Add_Click(sender As Object, e As EventArgs) Handles Btn_Add.Click
|
152 |
|
|
Me.Close()
|
153 |
|
|
End Sub
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
' Private Sub Procees()
|
158 |
|
|
' Dim indexes As ListView.SelectedIndexCollection =
|
159 |
|
|
' Me.ListView_File.SelectedIndices
|
160 |
|
|
' Dim index As Integer
|
161 |
|
|
|
162 |
|
|
' For Each index In indexes
|
163 |
|
|
' 'On Error Resume Next
|
164 |
|
|
' If folders_path.EndsWith("\") = True Then
|
165 |
|
|
' On Error GoTo out
|
166 |
|
|
' Me.Status_Main.Items(0).Text = folders_path + (Me.ListView_File.Items(index).Text)
|
167 |
|
|
' On Error GoTo out
|
168 |
|
|
' 'On Error Resume Next
|
169 |
|
|
' Else
|
170 |
|
|
' Me.Status_Main.Items(0).Text = folders_path + "\" + (Me.ListView_File.Items(index).Text)
|
171 |
|
|
' On Error GoTo out
|
172 |
|
|
' End If
|
173 |
|
|
|
174 |
|
|
' Dim infoReader As System.IO.FileInfo
|
175 |
|
|
' infoReader = My.Computer.FileSystem.GetFileInfo(Me.Status_Main.Items(0).Text)
|
176 |
|
|
' Me.Status_Main.Items(1).Text = " Created : " + infoReader.CreationTime.ToString + " " + infoReader.Attributes.ToString
|
177 |
|
|
' On Error GoTo out
|
178 |
|
|
' MsgBox(Me.Status_Main.Items(0).Text + " is processed")
|
179 |
|
|
' On Error GoTo out
|
180 |
|
|
' Next
|
181 |
|
|
' Exit Sub
|
182 |
|
|
'out:
|
183 |
|
|
' MsgBox(Err.Description)
|
184 |
|
|
' End Sub
|
185 |
|
|
End Class |