请大家帮看下伪代码,此处我用filecopy函数到本地磁盘速度很快,但是复制到移动磁盘就不一样,速度极慢,如果用WINDOWS的复制粘贴到移动磁盘都不会很慢的.能不能帮解决这个"复制到移动磁盘"极慢的问题,要求复制列表框list1选中的文件到text2目标路径中.Private Sub Command1_Click()
Dim mPath2 As String
Dim sFile As String
Dim i%
i = 0mPath2 = Trim(Text2.Text) 'Text2.Text保存了要复制的目的驱动器/目录
If Right(mPath2, 1) <> "\" Then mPath2 = mPath2 & "\"Do While i < List1.ListCount
If List1.Selected(i) = True Then '以list1框选中的文件对象sFile = mPath2 & Right(List1.List(i), Len(List1.List(i)) - InStrRev(List1.List(i), "\", Len(List1.List(i))))
filecopy List1.List(i), sFile '复制选中的文件对象到text2路径中去List1.RemoveItem i
Else
i = i + 1
End If
LoopEnd Sub
Dim mPath2 As String
Dim sFile As String
Dim i%
i = 0mPath2 = Trim(Text2.Text) 'Text2.Text保存了要复制的目的驱动器/目录
If Right(mPath2, 1) <> "\" Then mPath2 = mPath2 & "\"Do While i < List1.ListCount
If List1.Selected(i) = True Then '以list1框选中的文件对象sFile = mPath2 & Right(List1.List(i), Len(List1.List(i)) - InStrRev(List1.List(i), "\", Len(List1.List(i))))
filecopy List1.List(i), sFile '复制选中的文件对象到text2路径中去List1.RemoveItem i
Else
i = i + 1
End If
LoopEnd Sub
If Right(mPath2, 1) <> "\" Then mPath2 = mPath2 & "\" For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) = True Then '以list1框选中的文件对象 sFile = mPath2 & Mid(List1.List(i), InStrRev(List1.List(i), "\") + 1)
filecopy List1.List(i), sFile '复制选中的文件对象到text2路径中去 List1.RemoveItem i End If
Next i
为什么用WINDOWS系统直接复制粘贴能这么快的,我试过了,15首歌才用了15s左右,而用上面代码至少60s以上.
判断也省去了,结果还是快不了多少.
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Longcopyfile(源文件,目的文件,false)