Results 1 to 2 of 2

Thread: CopyFile from a:\*.* to c:\*.*

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Hongkong
    Posts
    7

    Post

    Hi there..

    What is the code for diskcopy all files from one selected drive to and other selected drive... for example copy everything from drive A to drive C root directory....?

    I try to use the following code in VB6 and I have (div1, drive1 and file1) in my form.

    copyfile "a:\*.*", "c:\*.*"

    and what is File System Object?

    Thank You

    Sheley

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Files System Object is a DLL (Scripting runtime library) by Microsoft.

    Yes, it supports what you ask, copying one directory into another, but then you will have to include this DLL along with your project. There's a VB way to do just that:

    Code:
    Public Sub CopyFromFloppy()
       Dim strFile As String
       Dim strDestFile As String
        
        
        strFile = Dir("A:\*.*")
        
        Do Until strFile = ""
            strDestFile = "C:\" & ParseFile(strFile)
            FileCopy "A:\" & strFile, strDestFile
            strFile = Dir
        Loop
    End Sub
    
    Public Function ParseFile(pFileName As 
    String) As String
    
    Do
            pFile = Mid$(strFileName, InStr(pFileName, "\") + 1)
        Loop While InStr(pFileName, "\") <> 0
        
        ParseFile = pFileName
    
    End Function
    Regards,


    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]



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