1

我将一些文件复制到某个目的地,同时我想将文件名记录在文本文件中。

如果文件已经存在于目标文件夹中(以使用户处于“已知”环境中),我想使用 Windows 7 复制/替换对话框。

但我的问题是我无法根据用户的选择捕捉 4 个不同的事件:

  • 代替
  • 请勿抄袭
  • 用不同的名字复制
  • 取消(对于这个我可以抛出异常并捕获它)

        Dim oFile As New StreamWriter(strTextFile)
        For Each p In Me.Files ' List of custom class with file information like Path, Extension, etc...
            Dim strFileName = Path.Combine(strDestinationFolder, p.FileName)
            If File.Exists(strFileName) Then
                Try
                    My.Computer.FileSystem.CopyFile(p.Path, strFileName, UIOption.AllDialogs, UICancelOption.ThrowException)
                Catch ex As Exception
                    ' I would like to catch user's choices here to react accordingly in the text file
                End Try
            Else
                oFile.WriteLine(p.Path & ";" & p.FileName)
            End If
        Next
        oFile.Close()
    

提前致谢。

4

0 回答 0