Vb.net 可以将多个文件作为一个批移入吗

Vb.net 可以将多个文件作为一个批移入吗,vb.net,file,move,Vb.net,File,Move,我想将多个文件从一个目录移动到另一个目录。我使用“My.Computer.FileSystem.MoveFile”,这很好,但它一次只能处理一个文件。因此,对于该目录中已存在的每个文件,我都会收到一条警告(即“文件已存在”),而不是批处理的一条警告。是否有可能对所有移动的文件发出警告 For i = .Items.Count - 1 To 0 Step -1 Dim map = .Items.Item(i).SubItems(COL_MAP).Te

我想将多个文件从一个目录移动到另一个目录。我使用“My.Computer.FileSystem.MoveFile”,这很好,但它一次只能处理一个文件。因此,对于该目录中已存在的每个文件,我都会收到一条警告(即“文件已存在”),而不是批处理的一条警告。是否有可能对所有移动的文件发出警告

       For i = .Items.Count - 1 To 0 Step -1

                Dim map = .Items.Item(i).SubItems(COL_MAP).Text
                Dim bestandHernoemd = .Items.Item(i).SubItems(COL_HERNOEMD).Text
                Dim bestandOrigineel = .Items.Item(i).SubItems(COL_ORIGINEEL).Text

                    Try

                        My.Computer.FileSystem.MoveFile(map & bestandOrigineel, My.Settings.OPTIE_OvernemenStandaardMapNaam & bestandHernoemd, Microsoft.VisualBasic.FileIO.UIOption.AllDialogs, Microsoft.VisualBasic.FileIO.UICancelOption.ThrowException)

                        .Items.RemoveAt(i)                               

                    Catch ex As Exception

                        foutLijst.Add(bestandOrigineel & ": " & ex.Message)

                    End Try
        Next

如果要将文件(所有文件夹、子文件夹、文件或子文件)从一个源递归复制到目标,可以使用以下子过程。未应用任何警告,并将覆盖目的地

Public Sub CopyDirectory(ByVal sourcePath As String, ByVal destinationPath As String)
   Dim sourceDirectoryInfo As New System.IO.DirectoryInfo(sourcePath)
        'If the destination folder doesn't exist then create it'
      If Not System.IO.Directory.Exists(destinationPath) Then
            'Obs, folder doesn't exist, create one please :)'
         System.IO.Directory.CreateDirectory(destinationPath)
      End If
   Dim fileSystemInfo As System.IO.FileSystemInfo
       For Each fileSystemInfo In sourceDirectoryInfo.GetFileSystemInfos
         Dim destinationFileName As String = System.IO.Path.Combine(destinationPath, fileSystemInfo.Name)
            'Now check whether its a file or a folder and take action accordingly
            If TypeOf fileSystemInfo Is System.IO.FileInfo Then
              System.IO.File.Copy(fileSystemInfo.FullName, destinationFileName, True)
            Else
              ' Recursively call the method to copy all the nested folders
              CopyDirectory(fileSystemInfo.FullName, destinationFileName)
            End If
       Next
End Sub

使用函数的
MoveFile(SourceFileName、DestFileName、Overwrite)
版本。它仍然一次只移动一个文件,但将
覆盖
指定为
将完全阻止显示警告。谢谢你的回答,但我不希望文件被那样覆盖。我需要一个警告,看看我是否要覆盖该文件。这没有意义。您可能希望每个文件都有一个通知(以查看是否需要替换单个文件),或者根本不希望收到任何警告。如果要检查每个文件以进行替换,则不能对多个文件发出一个警告。是的,这是有意义的。是的,你可以!看看Windows资源管理器是如何处理这个问题的,也许这就是答案所在。我想我必须像这样建立我自己的定制复制表单:()谢谢你的回答。我需要那个警告来查看是否需要替换文件。