Results 1 to 19 of 19

Thread: [RESOLVED] USB drive backup program

Threaded View

  1. #14

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Re: USB drive backup program

    This is my code

    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
    What exactly does the 'sleep' command do?
    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.
    Last edited by winterslam; Jan 10th, 2008 at 12:11 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width