This is my code
What exactly does the 'sleep' command do?Code:Option Explicit Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Dim fso As New FileSystemObject Public Sub FolderCopy(ByVal source As String, ByVal destination As String) Dim objfile As File Dim objfolder As Folder DoEvents For Each objfile In fso.GetFolder(source).Files DoEvents On Error Resume Next If objfile.Name <> "" Then objfile.Copy destination + "\" + objfile.Name, True Sleep 100 End If Next For Each objfolder In fso.GetFolder(source).SubFolders DoEvents On Error Resume Next If Dir(destination + "\" + objfolder.Name) = "" Then MkDir destination + "\" + objfolder.Name FolderCopy objfolder.Path, destination + "\" + objfolder.Name Next End Sub Private Sub Command1_Click() FolderCopy "E:", "C:\Rescued" End Sub Private Sub Form_Unload(Cancel As Integer) Set fso = Nothing End Sub
Does it pause my program for some milliseconds while allowing other processes to run smoothly?
But I got great results from this code.
The last step is to get the drive letters of the inserted removable drives.




Reply With Quote