MoveFile Function

Declare Function MoveFile Lib "kernel32.dll" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long

Platforms: Win 32s, Win 95/98, Win NT

MoveFile moves or renames a file or directory -- it's really the same operation either way. If a directory is moved/renamed, all of the subdirectories and files contained in it will similarly be moved/renamed to reflect the path change. The function returns 1 if successful, or 0 if an error occured.

lpExistingFileName
The source file or directory; i.e., the file or directory to rename (move).
lpNewFileName
The target file or directory; i.e., the new file or directory name to give the source file (where to move the file or directory).

Example:

' Move the file to C:\MyFiles\temp.txt to C:\Dummy\buffer.txt.
' The original file will no longer exist.  Note how this example both changes
' the filename and moves the file into a different directory simultaneously.
Dim retval As Long  ' return value

retval = MoveFile("C:\MyFiles\temp.txt", "C:\Dummy\buffer.txt")

See Also: CopyFile
Category: Files

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/m/movefile.html