ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Moving the file
  • Renaming a directory
  • Renaming an HFSQL data 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
Modifies the name of a file.
WINDEVJavaUser code (UMC)
// Modify the name of a file
Res = fRename("C:\Directory\File.doc", "C:\Directory\RenamedFile.doc")
 
 
// Modify the name of the file while moving the file
Res = fRename("C:\Directory\File.doc", "C:\Temp\RenamedFile.doc")
 
// Modify the name of the file while moving the file into the current directory
Res = fRename("C:\Directory\File.doc", "RenamedFile.doc")
Syntax
<Result> = fRename(<Path of file to rename> , <New file path>)
<Result>: Boolean
  • True if the modification was performed,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Path of file to rename>: Character string
  • Full path of the file to rename (up to 260 characters). A UNC path can be used.
  • Relative path in relation to the current directory (returned by fCurrentDir). Wildcard characters are not allowed.
WindowsLinux This parameter can be in Ansi or Unicode format.
<New file path>: Character string
  • Full path of the file with the new name (up to 260 characters). A UNC path can be used.
  • Relative path in relation to the current directory (returned by fCurrentDir).
Wildcard characters are not allowed. The path of the file must exist.
WindowsLinux This parameter can be in Ansi or Unicode format.
Remarks

Moving the file

If <Path of file to rename> and <New file path> contain the same file name but different access paths, fRename moves the file.

Renaming a directory

fRename can also be used to rename a directory. To rename a directory, the directory to rename must be different from the current directory of the application.

Renaming an HFSQL data file

To rename an HFSQL data file, use HChangeName.

Handling errors

fRename throws an error in the following cases:
  • the file to rename does not exist,
  • the file to rename is locked,
  • the path of the file to rename is invalid,
  • <New file path> or <Path of file to rename> is an empty string,
  • the new file already exists.
Remark: This function operates on an empty file.
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
Exemplo Renomear Arquivo
b_renomear is boolean=fRename(SAI_Arquivo,SAI_ArquivoNovo)
//frances
b_renomear=fRenomme(SAI_Arquivo,SAI_ArquivoNovo)

mostra_arquivos()

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/03/curso-windev-arquivos-005-arquivos.html
De matos AMARILDO
23 Mar. 2016

Last update: 08/23/2022

Send a report | Local help