FTP サーバーのディレクトリとファイルを ListView に表示したいと考えています。私は ListViews を初めて使用するので、誰かが私を始めるのを手伝ってくれませんか?
コード:
Dim newSelected As TreeNode = e.Node
ListView1.Items.Clear()
Dim nodeDirInfo As DirectoryInfo = _
CType(newSelected.Tag, DirectoryInfo)
Dim subItems() As ListViewItem.ListViewSubItem
Dim item As ListViewItem = Nothing
Dim dir As DirectoryInfo
For Each dir In nodeDirInfo.GetDirectories()
item = New ListViewItem(dir.Name, 0)
subItems = New ListViewItem.ListViewSubItem() _
{New ListViewItem.ListViewSubItem(item, "Directory"), _
New ListViewItem.ListViewSubItem(item, _
dir.LastAccessTime.ToShortDateString())}
item.SubItems.AddRange(subItems)
ListView1.Items.Add(item)
Next dir
Dim file As FileInfo
For Each file In nodeDirInfo.GetFiles()
item = New ListViewItem(file.Name, 1)
subItems = New ListViewItem.ListViewSubItem() _
{New ListViewItem.ListViewSubItem(item, "File"), _
New ListViewItem.ListViewSubItem(item, _
file.LastAccessTime.ToShortDateString())}
item.SubItems.AddRange(subItems)
ListView1.Items.Add(item)
Next file