MoveDirectory Method


MoveDirectory Method

Location

My.Computer.FileSystem.MoveDirectory

Syntax

     My.Computer.FileSystem.MoveDirectory(source, _        destination[, overwrite]) 

or:

     My.Computer.FileSystem.MoveDirectory(source, _        destination, showUI[, onUserCancel]) 


source (required; String)

The path of the directory to be moved.


destination (required; String)

The path of the parent directory to which the source directory will be moved.


overwrite (optional; Boolean)

Indicates whether an existing directory at the destination should be overwritten (true) or not (False). If this parameter is missing from the first syntax, it defaults to False.


showUI (required in syntax 2; UIOption enumeration)

Indicates whether error or progress dialog windows should appear during the move. One of the following Microsoft.VisualBasic.FileIO.UIOption enumeration values.

Value

Description

OnlyErrorDialogs

Only shows error dialog boxes; does not display progress

AllDialogs

Shows progress and error dialogs


If this parameter is missing, OnlyErrorDialogs is used by default.


onUserCancel (optional; UICancelOption enumeration)

The progress window includes a Cancel button. When pressed, the method takes action based on this parameter. One of the following Microsoft.VisualBasic.FileIO.UICancelOption enumeration values.

Value

Description

DoNothing

Aborts the move but returns no information indicating that the move was cancelled

ThrowException

Throws an exception


If this parameter is missing, ThrowException is used by default.

Description

The MoveDirectory method moves the indicated directory and all files within it to a new parent directory.

Usage at a Glance

  • If the destination directory, though valid, does not exist, it will be created.

  • An exception is thrown if the source or destination parameters are missing or invalid.

  • An exception is thrown if the source directory does not exist or is in use (including any included files), or if a directory to be overwritten is in use.

  • An exception is thrown if the user lacks sufficient file access permissions.

  • An exception is thrown if the source and destination are the same or the source contains the destination.

Example

The following example moves a directory to a new parent directory.

     My.Computer.FileSystem.MoveDirectory( _        ("C:\Project\Documents", "C:\Archive") 

Related Framework Entries

  • Microsoft.VisualBasic.FileIO.FileSystem.MoveDirectory Method

  • Microsoft.VisualBasic.MyServices.FileSystemProxy.MoveDirectory Method

  • System.IO.Directory.Move Method

See Also

CopyDirectory Method, CopyFile Method, CreateDirectory Method, DeleteDirectory Method, DeleteFile Method, FileSystem Object, MoveFile Method, RenameDirectory Method, RenameFile 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