Copy Folders in C# using System.IO

后端 未结 9 823
傲寒
傲寒 2020-12-10 03:20

I need to Copy folder C:\\FromFolder to C:\\ToFolder

Below is code that will CUT my FromFolder and then will create my ToFolder. So my FromFolder will be gone and al

9条回答
  •  有刺的猬
    2020-12-10 04:02

    This article provides an alogirthm to copy recursively some folder and all its content

    From the article :

    Sadly there is no built-in function in System.IO that will copy a folder and its contents. Following is a simple recursive algorithm that copies a folder, its sub-folders and files, creating the destination folder if needed. For simplicity, there is no error handling; an exception will throw if anything goes wrong, such as null or invalid paths or if the destination files already exist.

    Good luck!

提交回复
热议问题