Location My.Computer.FileSystem.MoveFile Syntax My.Computer.FileSystem.MoveFile(source, destination[, overwrite]) or: My.Computer.FileSystem.MoveFile(source, destination, _ showUI[, onUserCancel])
source (required; String) The path of the file to be moved.
destination (required; String) The path of the directory to which the file will be moved.
overwrite (optional; Boolean) Indicates whether an existing file 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 MoveFile method moves the indicated file to a new 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 file does not exist or is in use, or if a file to be overwritten is in use. An exception is thrown if the user lacks sufficient file access permissions. Example The following example moves a file to a new directory, overwriting any existing file of the same name. My .Computer.FileSystem.MoveFile( _ ("C:\SourceDir\workfile.txt", "C:\DestDir", True) Related Framework Entries Microsoft.VisualBasic.FileIO.FileSystem.MoveFile Method Microsoft.VisualBasic.MyServices.FileSystemProxy.MoveFile Method System.IO.File.Move Method See Also CopyDirectory Method, CopyFile Method, CreateDirectory Method, DeleteDirectory Method, DeleteFile Method, FileSystem Object, MoveDirectory Method, RenameDirectory Method, RenameFile Method |