代码如下 (一般在button的onclick事件中)
Dim fb As New FolderBrowserDialog
If fb.ShowDialog = Windows.Forms.DialogResult.OK Then
For Each flsN As String In Directory.GetFiles(fb.SelectedPath)
Dim strfile() As String = flsN.Split("\")
Dim fileaname As String = strfile(strfile.Length - 1)
If userHelper.RfileNameshortList.Contains(fileaname) Then 'userHelper.RfileNameshortList 这个集合保存了需要接收的所有文件名字
Dim dr As DialogResult = MsgBox("是否覆盖" + vbCr & vbLf + fileaname, MsgBoxStyle.OkCancel, "有同名文件") '弹出提示对话框
If dr = Windows.Forms.DialogResult.OK Then
’点击确定之后执行的功能
Else
’点击取消之后执行的功能
End If
End If
Next