How to move a directory in C #
Move a file or a directory and its contents to a new location.
using System.IO;
class MoveDirectoryTest
{
public static void Main()
{
// Path of the directory to be moved.
string sourcePathOfDirectory = "C:\\Documents and Settings\\User\\MyDirectory";
// New directory path.
string destinationPathOfDirectory = "D:\\MyDirectory";
Directory.Move(sourcePathOfDirectory, destinationPathOfDirectory);
}
}
This method throws an IOException if you try to move C:\\Documents and Settings\\User\\MyDirectory to D:\\MyDirectory, and D:\\MyDirectory already exists.
Category: C#