Copying a Directory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Galey

    #1

    Copying a Directory

    In VB.NET, is there any way to copy a directory and all its contents to a
    new location using io.Directory or io.DirectoryInf o etc. without having to
    import the Scripting.FileS ystemObject?

    io.Directory and DirectoryInfo only seem to have a Move command, but what
    about copying?



  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: Copying a Directory

    Phil,
    You can use IO.File.Copy to copy a file.

    I would use IO.Directory.Ge tDirectories to get the list of directories &
    Directory.GetFi les to get the list of files in a directory. I would then use
    Directory.Creat eDirectory to "copy" the Directory entries & File.Copy to
    copy each file.

    Post if you would like a sample.

    Hope this helps
    Jay

    "Phil Galey" <pagaley@starca lif.com.nospam> wrote in message
    news:%23mWV7mdd FHA.2124@TK2MSF TNGP14.phx.gbl. ..
    | In VB.NET, is there any way to copy a directory and all its contents to a
    | new location using io.Directory or io.DirectoryInf o etc. without having to
    | import the Scripting.FileS ystemObject?
    |
    | io.Directory and DirectoryInfo only seem to have a Move command, but what
    | about copying?
    |
    |
    |


    Comment

    • Crouchie1998

      #3
      Re: Copying a Directory

      Hi Phil,

      Here's a code sample to do just that:



      Not downloaded it myself to check the code for you - sorry

      Crouchie1998
      BA (HONS) MCP MCSE


      Comment

      • Cor Ligthert

        #4
        Re: Copying a Directory

        Phil,

        Nobody prevents you to use XCopy in an application start.

        Just my thought,

        Cor


        Comment

        Working...