FileSystemObject.MoveFile Method (VB6)

Named Arguments

Yes

Syntax

oFileSysObj.MoveFile source , destination


oFileSysObj

Use: Required

Data Type: FileSystemObject object

Any object variable returning a FileSystemObject object.


source

Use: Required

Data Type: String

The path to the file or files to be moved.


destination

Use: Required

Data Type: String

The path to the location where the file or files are to be moved.

Description

Moves a file from one folder to another.

Rules at a Glance

  • If source contains wildcard characters or if destination ends in a path separator, destination is interpreted as a path; otherwise, its last component is interpreted as a filename.

  • If the destination file exists, an error occurs.

  • source can contain wildcard characters, but only in its last component.

  • destination can't contain wildcard characters.

  • Both source and destination can be either absolute or relative paths.

  • Both source and destination can be network paths or share names.

Programming Tips and Gotchas

  • MoveFile resolves both arguments before beginning the operation.

  • Any single file move operation is atomic; that is, any file removed from source is copied to destination. However, if an error occurs while multiple files are being moved, the execution of the function terminates, but files already moved aren't moved back to their previous folder. If a fatal system error occurs during the execution of this method (like a power failure), the worst that can happen is that the affected file is copied to the destination but not removed from the source. There are no rollback capabilities built into the File.Move method, however, since, because the copy part of this two-stage process is executed first, the file can't be lost. But while there is no chance of losing data, particularly in multifile operations, it's more difficult to determine whether the move operations have succeeded or not. This is because an error at any time while files are being moved causes the MoveFile method to be aborted.

  • You can use the GetAbsolutePath, FolderExists, and FileExists methods prior to calling the MoveFile method to ensure its success.

See Also

FileSystemObject.CopyFile Method, FileSystemObject.FileExists Method, FileSystemObject.GetAbsolutePath Method, File.Move Method
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.39.93