C# 使用vb.net将文件夹从复选框1移动到2

C# 使用vb.net将文件夹从复选框1移动到2,c#,mysql,vb.net,C#,Mysql,Vb.net,我有两个复选框。一个是我要复制的文件夹列表。第二个是我要将文件夹复制到的位置列表 Private Sub moveContainerToLocation_Click(sender As System.Object, e As System.EventArgs) Handles moveContainerToLocation.Click 'To do Try Dim fileToCopy As String Dim NewCopy As String

我有两个复选框。一个是我要复制的文件夹列表。第二个是我要将文件夹复制到的位置列表

Private Sub moveContainerToLocation_Click(sender As System.Object, e As System.EventArgs) Handles moveContainerToLocation.Click
    'To do
    Try
        Dim fileToCopy As String
        Dim NewCopy As String
        Dim fileSize As Long


        ' fileToCopy is folder i want to move 
        ' NewCopy  is the location what we choose to move the folder to



        fileToCopy = "C:\folder test"
        NewCopy = "C:\folder"
        fileSize = GetFolderSize(fileToCopy)

        ' allow to overwrite
        My.Computer.FileSystem.CopyDirectory(fileToCopy, NewCopy, True)
        Timer1.Start()
        moveContainerToLocation.Enabled = False


        ' the percentage of files transferred and use it into the progressbar
        Dim counter =Directory.GetFiles(fileToCopy,"*",SearchOption.AllDirectories).Length
        'Next
    Catch ex As Exception
       MessageBox.Show("ERROR")
    End Try
End Sub
问题是我不知道如何单击复选框并移动到该位置。我所做的就是设置一个固定位置,我可以从文件夹测试复制到文件夹。但我想选择清单中的勾号,从框1移动到框2,而不是固定的位置和文件夹

Private Sub moveContainerToLocation_Click(sender As System.Object, e As System.EventArgs) Handles moveContainerToLocation.Click
    'To do
    Try
        Dim fileToCopy As String
        Dim NewCopy As String
        Dim fileSize As Long


        ' fileToCopy is folder i want to move 
        ' NewCopy  is the location what we choose to move the folder to



        fileToCopy = "C:\folder test"
        NewCopy = "C:\folder"
        fileSize = GetFolderSize(fileToCopy)

        ' allow to overwrite
        My.Computer.FileSystem.CopyDirectory(fileToCopy, NewCopy, True)
        Timer1.Start()
        moveContainerToLocation.Enabled = False


        ' the percentage of files transferred and use it into the progressbar
        Dim counter =Directory.GetFiles(fileToCopy,"*",SearchOption.AllDirectories).Length
        'Next
    Catch ex As Exception
       MessageBox.Show("ERROR")
    End Try
End Sub
''这是在我的checklistbox1中获取我的文件夹

Private Sub moveContainerToLocation_Click(sender As System.Object, e As System.EventArgs) Handles moveContainerToLocation.Click
    'To do
    Try
        Dim fileToCopy As String
        Dim NewCopy As String
        Dim fileSize As Long


        ' fileToCopy is folder i want to move 
        ' NewCopy  is the location what we choose to move the folder to



        fileToCopy = "C:\folder test"
        NewCopy = "C:\folder"
        fileSize = GetFolderSize(fileToCopy)

        ' allow to overwrite
        My.Computer.FileSystem.CopyDirectory(fileToCopy, NewCopy, True)
        Timer1.Start()
        moveContainerToLocation.Enabled = False


        ' the percentage of files transferred and use it into the progressbar
        Dim counter =Directory.GetFiles(fileToCopy,"*",SearchOption.AllDirectories).Length
        'Next
    Catch ex As Exception
       MessageBox.Show("ERROR")
    End Try
End Sub
Private Sub GetfolderButton_Click(sender As System.Object, e As System.EventArgs) Handles GetContainerButton.Click

    For Each dra As String In Directory.GetDirectories("C:\folder test")
        Container.Items.Add(dra)
    Next

End Sub
''这是为了获取我在checklistbox1中的位置

Private Sub moveContainerToLocation_Click(sender As System.Object, e As System.EventArgs) Handles moveContainerToLocation.Click
    'To do
    Try
        Dim fileToCopy As String
        Dim NewCopy As String
        Dim fileSize As Long


        ' fileToCopy is folder i want to move 
        ' NewCopy  is the location what we choose to move the folder to



        fileToCopy = "C:\folder test"
        NewCopy = "C:\folder"
        fileSize = GetFolderSize(fileToCopy)

        ' allow to overwrite
        My.Computer.FileSystem.CopyDirectory(fileToCopy, NewCopy, True)
        Timer1.Start()
        moveContainerToLocation.Enabled = False


        ' the percentage of files transferred and use it into the progressbar
        Dim counter =Directory.GetFiles(fileToCopy,"*",SearchOption.AllDirectories).Length
        'Next
    Catch ex As Exception
       MessageBox.Show("ERROR")
    End Try
End Sub
Private Sub getLocationButton_Click(sender As System.Object, e As System.EventArgs) Handles getLocationButton.Click

    For Each dr As String In Directory.GetDirectories("C:\folder")
        Location.Items.Add(dr)
    Next



End Sub

如果我正确理解了您的问题,您会问如何在
CheckedListBox
中获取选中的项目,对吗?第一件事是,CheckedListBox`中可能有多个选中项。所以你不会得到一个答案

Private Sub moveContainerToLocation_Click(sender As System.Object, e As System.EventArgs) Handles moveContainerToLocation.Click
    'To do
    Try
        Dim fileToCopy As String
        Dim NewCopy As String
        Dim fileSize As Long


        ' fileToCopy is folder i want to move 
        ' NewCopy  is the location what we choose to move the folder to



        fileToCopy = "C:\folder test"
        NewCopy = "C:\folder"
        fileSize = GetFolderSize(fileToCopy)

        ' allow to overwrite
        My.Computer.FileSystem.CopyDirectory(fileToCopy, NewCopy, True)
        Timer1.Start()
        moveContainerToLocation.Enabled = False


        ' the percentage of files transferred and use it into the progressbar
        Dim counter =Directory.GetFiles(fileToCopy,"*",SearchOption.AllDirectories).Length
        'Next
    Catch ex As Exception
       MessageBox.Show("ERROR")
    End Try
End Sub
If CheckedListBox1.CheckedItems.Count = 0 Then
    MsgBox("Please select something")
    Return
ElseIf CheckedListBox1.CheckedItems.Count > 1 Then
    MsgBox("Please select only one item")
    Return

End If

NewCopy = CheckedListBox1.CheckedItems(0)