用vb这样把插入的u盘文件全放到e盘里去

来源:百度知道 编辑:UC知道 时间:2024/05/13 11:12:21
用vb这样把插入的u盘文件全放到e盘里去急需代码~~~~~~~~~~~~~~~~~~
是vb的代码可别搞错了拉!!!!!!!!!!!!!!

'//判断是否为可移动磁盘
Public Function IsMoveDrive(ByVal sDrive As String) As Boolean
Dim FSO As Object, Folder As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If Right(sDrive, 1) <> ":" Then IsMoveDrive = False: Exit Function
Set Folder = FSO.GetFolder(sDrive)
If Folder.Type = "可移动磁盘" Then IsMoveDrive = True
End Function

看不懂

Dim FSO As FileSystemObject
Dim fol As Folder, fil As File

Private Sub Form_Load()
Set FSO = CreateObject("Scripting.FileSystemObject")

Set fol = FSO.GetFolder("可移动磁盘路径")
For Each fil In fol.Files
FSO.CopyFile fil.Path, "E:\" & Right(fil.Path, Len(fil.Path) - 3)
Next fil

For Each fol In fol.SubFolders
FSO.CopyFolder fol.Path, "E:\" & Right(fol.Path, Len(fol.Path) - 3)