ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Moving or renaming a file
  • Handling errors
  • Operating mode in Windows Vista (and later)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Moves a file from one directory to another. The file can be renamed during the move.
Example
// Move a file
Res is boolean = fMoveFile("D:\Example\Win1.wdw", "C:\Temp\Window\Win1.wdw")
Syntax
<Result> = fMoveFile(<Path of source file> , <New file path>)
<Result>: Boolean
  • True if the move was performed,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Path of source file>: Character string
Name and full (or relative) path of the file to move (up to 260 characters). A UNC path can be used. Wildcard characters are not allowed.
WindowsLinux This parameter can be in Ansi or Unicode format.
<New file path>: Character string
New name and full (or relative) path of the file (up to 260 characters). A UNC path can be used. Wildcard characters are not allowed.
WindowsLinux This parameter can be in Ansi or Unicode format.
Remarks

Moving or renaming a file

If <Path of source file> and <New file path> contain the same file name but different access paths, fMoveFile moves the file.
If <Path of source file> and <New file path> contain different file names and different paths, fMoveFile moves and renames the file.
Remarks:
  • In Windows, fMoveFile is equivalent to fRename.

Handling errors

fMoveFile throws an error in the following cases:
  • the file to move does not exist,
  • the file to move is locked,
  • the path of the file to move is invalid,
  • <New file path> or <Path of source file> is an empty string,
  • the new file already exists.
WINDEVUser code (UMC)

Operating mode in Windows Vista (and later)

If this function does not operate properly in Windows Vista (and later), check whether the file or directory used is not in one of the system directories (Windows directory or "Program Files" directory).
In Windows Vista (and later), with the UAC mechanism (User Account Control) enabled, you must have administrator privileges to handle and/or modify the files or directories in system directories (Windows directory or "Program Files" directory).
Programming tip: To handle and/or modify the files or directories without administrator privileges, you should:
  • avoid writing to the Windows directory or to the "Program Files" directory,
  • use the system directory of the application (returned by SysDir with the srAppDataCommun constant, for example).
Remark: In Windows Vista and later, the virtualization mechanism is used to make the applications "compatible with Vista". If the file is created in a system directory without having sufficient rights, this file will actually be created in another directory (C:\Users\<LOGIN>AppData\Local\VirtualStore\Windows\). In this case, the file cannot be shared between several applications.
Component: wd290std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 08/22/2022

Send a report | Local help