制作一个VB复制文件的程序!
command1选择要复制到的目录text1显示要复制到的目录command2复制按钮要将C:\a\1.exe和c:\a\2.exe复制到选择文件夹中的子目录中去如:复制...
command1 选择要复制到的目录 text1 显示要复制到的目录command2 复制按钮要将 C:\a\1.exe 和 c:\a\2.exe 复制到选择文件夹中的子目录中去如:复制到 C:\ABC\123\456
如果里面存在 \123\456 目录就直接复制。如果不存在要有提示!
选择目标文件夹 就选C:\ABC 就可以 检测 123 和 456 目录是否存在。因为
还有其他文件要 复制
进去
谢谢了! 展开
如果里面存在 \123\456 目录就直接复制。如果不存在要有提示!
选择目标文件夹 就选C:\ABC 就可以 检测 123 和 456 目录是否存在。因为
还有其他文件要 复制
进去
谢谢了! 展开
1个回答
2015-05-17
展开全部
界面
代码
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pIdl As Long, ByVal pszPath As String) As Long
Private Type BrowseInfo
hwndOwner As Long
piDLroot As Long
pszdisplayName As String
lpsztitle As String
ulFlags As Long
lpfncallback As Long
lParam As Long
iImage As Long
End Type
Private Sub Command1_Click()
If Dir(Text1.Text & "\123\456", vbDirectory) <> "" Then
FileCopy "C:\a\1.exe", Text1.Text & "\123\456\1.exe"
FileCopy "C:\a\2.exe", Text1.Text & "\123\456\2.exe"
Else
MsgBox Text1.Text & "\123\456 文件夹不存在!"
End If
End Sub
Private Sub Command2_Click()
Dim bi As BrowseInfo
Dim folderid As Long
Dim pb As String
With bi
.hwndOwner = Me.hWnd
.lpsztitle = "要复制到的目录:"
.ulFlags = 3
End With
folderid = SHBrowseForFolder(bi)
If folderid = 0 Then Exit Sub
pb = String$(260, 0)
SHGetPathFromIDList folderid, pb
pb = Left$(pb, InStr(pb, vbNullChar) - 1)
Text1.Text = pb
End Sub
请采纳
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询