我有一个文件夹 (1) 将填满文件,这些文件将显示在 ListViewBox 中,旁边有一个复选框。我试图弄清楚当按下 Button1 并选中文件名旁边的复选框时,它将将该文件移动到下一个文件夹(2)。(想法是文件夹 1 中可能有 10 个文件,用户可以选择将哪些文件移动到文件夹 2)。
我正在努力让For Each
循环为我工作ListView
。我曾尝试使用My.Computer.Filesystem.Move
and IO.File.Move
,但我很难将它们与每个文件一起更改的文件名与列表视图框中的选中项目联系起来。任何帮助将不胜感激。
这是我的代码:
Public Class Form1
Public MySource As String = "C:\DataEntryTest\LogFiles\"
Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim folderinfo As IO.DirectoryInfo = New IO.DirectoryInfo(MySource)
ListView1.FullRowSelect = True
ListView1.CheckBoxes = True
With ListView1
.Clear()
.View = View.Details
.Columns.Add("Name", 150)
For Each myFile As IO.FileInfo In folderinfo.GetFiles
Dim myListItem As ListViewItem = New ListViewItem(myFile.Name)
.Items.Add(myListItem)
Next
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class