Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jul 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    57
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Copy a folder's contents to another PC on the ntwk (Access 2000 SR1)

    I need to allow my users to copy an entire folder from their PC to another PC on the network. I have provided a form for the user to choose the source and destination paths but how do I easily copy all of the files within the folder to the destination path using code? I have done something similar for copying a specific file but am not sure how to handle copying an entire folder and it's contents. Any suggestions?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copy a folder's contents to another PC on the ntwk (Access 2000 SR1)

    If your directory don't contain subdirectories use :
    <pre>Shell "COPY " & strSourceDir & "*.* " & strDestinationDir</pre>

    Otherwise you could use xcopy.
    <pre>Shell "XCOPY " & strSourceDir & " " & strDestinationDir & " /S /I"</pre>

    You should also check that strSourceDir and strDestinationDir contains the necessary at the end of the string and add it if not.
    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Copy a folder's contents to another PC on the ntwk (Access 2000 SR1)

    Another alternative, is to use FileCopy, which is part of VBA. You could use the Dir function to return each filename, store them in an arry, and then do something like this to copy each filename stored in the array:

    [/pre]If Dir(strDestPath) = "" Then
    'if it doesn't already exist, copy it
    FileCopy strSourcePath, strDestPath ' Copy source to destination.
    End If[/pre]

    This particular snippet tests to see if the file already exists in the destination folder before copying it. If it does exist, you have to kill the old copy or FileCopy will fail.
    Charlotte

Posting Permissions

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