how to copy directory ?

Hi People,

i was going through the API regarding copying of a directory from one location to another, however, the MSDN always seems to point back to the "Directory" class to do the copying. However i could not find any examples which could help me or show me what needs to be called and passed in when using the Direcory class to copy whole directories.




Answer this question

how to copy directory ?

  • jrett

    The easiest way is to use the SHFileOperation API function.  This way you get the exact same results as if you were copying using Windows Explorer.

    If you need sample code let me know, otherwise you can google it.

  • Jamie Wakeam - MS

    If you add a reference to Microsoft.VisualBasic.dll, you can access this method:

    Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory

    VB2005 exposes this in the My namespace...


    Edit: I just looked at it in Reflector, this method is basically a wrapper around SHFileOperation...



  • Prospery

    Hi people, hate to break the news, but does VS .NET 2003 has such an option of using the Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory

    I am currently coding in C# and my project has been running for 4 yrs, so using VS 2005 isn't an option really

  • how to copy directory ?