Directory.Move Method


Directory.Move Method

Class

System.IO.Directory

Syntax

     Directory.Move(sourceDirName, destDirName) 


sourceDirName (required; String)

The name of the directory to be moved


destDirName (required; String)

The location to which the source directory and its contents are to be moved

Description

The Move method moves a directory and all its contents, including nested subdirectories and their files, to a new location.

Usage at a Glance

  • sourceDirName and destDirName can be either absolute paths or relative paths from the current directory. destDirName must include the name to be assigned to the moved directory. This allows you to change the directory name as you move it.

  • sourceDirName and destDirName can be either paths on the local system, the paths of a mapped network drive, or UNC paths.

  • Neither sourceDirName nor destDirName can contain wildcard characters.

  • If the directory indicated by destDirName already exists, an error occurs.

Example

The statement:

     Directory.Move("c:\folder1", "c:\folder2") 

moves folder1 to folder2 in the root of the C drive. That is, it moves all items found within folder1 to a new directory named folder2 and removes the original folder1.

Version Differences

Visual Basic 2005 includes a My.Computer.FileSystem.MoveDirectory method that provides similar functionality.

See Also

Directory.Delete Method




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net