RenameDirectory Method


RenameDirectory Method

Location

My.Computer.FileSystem.RenameDirectory

Syntax

     My.Computer.FileSystem.RenameDirectory(path, newName) 


path (required; String)

The path to the directory to be renamed.


newName (required; String)

The new name of the directory. Include the basic directory name only; do not include drive, parent directory, or path information.

Description

The RenameDirectory method renames an existing directory, keeping it in the same parent directory.

Usage at a Glance

  • The renamed directory always remains in the original parent directory. To move a directory to a different location on the same drive and rename it at the same time, use the MoveDirectory method instead.

  • Visual Basic includes a Rename statement that also renames directories.

  • An exception is thrown if the path or newName parameters are missing or invalid or if the newName parameter contains any path-specific information.

  • An exception is thrown if the directory does not exist or is in use (including any files contained within it) or if there is already a file or directory using the new name.

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

Example

The following example renames a directory.

 My.Computer.FileSystem.RenameDirectory("C:\vb_data", "vb_info") 

Related Framework Entries

  • Microsoft.VisualBasic.FileIO.FileSystem.RenameDirectory Method

  • Microsoft.VisualBasic.MyServices.FileSystemProxy.RenameDirectory Method

  • System.IO.Directory.Move Method (if moving in same parent directory)

See Also

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