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")

Related Call: CopyFile
Category: Files
Back to the index.


Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/m/movefile.html