C# DirectoryInfo MoveTo
Description
DirectoryInfo MoveTo
Moves a DirectoryInfo instance
and its contents to a new path.
Syntax
DirectoryInfo.MoveTo
has the following syntax.
public void MoveTo(
string destDirName
)
Parameters
DirectoryInfo.MoveTo
has the following parameters.
destDirName
- The name and path to which to move this directory. The destination cannot be another disk volume or a directory with the identical name. It can be an existing directory to which you want to add this directory as a subdirectory.
Returns
DirectoryInfo.MoveTo
method returns
Example
Moves a DirectoryInfo instance and its contents to a new path.
using System;/* ww w .j a v a 2 s . co m*/
using System.IO;
public class MoveToTest
{
public static void Main()
{
DirectoryInfo di = new DirectoryInfo("TempDir");
di.MoveTo("NewTempDir");
}
}
The code above generates the following result.