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 drive and its contents are to be moved

Return Value

None

Description

Moves a directory and all its contents, including nested subdirectories and their files, to a new location

Rules at a Glance

  • sourcedirname can be either an absolute path (a fully qualified path from the root directory to the directory to be moved) or a relative path (starting from the current directory to the directory to be moved).

  • sourcedirname and destdirname can be either a path on the local system, the path of a mapped network drive, or a UNC path.

  • Neither sourcedirname nor destdirname can contain wildcard characters .

  • destdirname must be either a fully qualified path or a relative path.

  • destdirname can also be an absolute path or a relative path, except that it must include the name to be assigned to the moved directory. This allows you to rename the directory at the same time as you move it.

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

Example

Suppose that the C drive contains the following folders:

 c:\docs\letters c:\Documents and Settings 

Moving the letters folder to make it a subdirectory of c:\Documents and Settings is done by the following code:

 Directory.Move("c:\docs\letters", _                "c:\Documents and Settings\letters") 

Thus, the first argument is the fully qualified name of the folder to move. The second argument is the path that results after the move is made , whereas one might have expected this argument to be the target folder for letters, which is c:\ Documents and Settings .

See Also

Directory.Delete Method

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

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