O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.2. Copying, moving, and deleting directories

For deleting and moving a directory and its contents, both Directory and DirectoryInfo contain the following methods shown in Table 18.4.

Table 18.4. Methods to use for performing common directory operations
FunctionSystem.IO.DirectoryInfoSystem.IO.Directory
Copying a directoryNo methodNo method
Moving a directoryMoveTo(string destination_path)Move(string source_path, string destination_path)
Deleting a directoryDelete()Delete(string path)

Note that there is no method for copying a whole directory and its contents. You will have to perform manual copying of each file within.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required