- Operating mode in Windows Vista (and later)
In french: fSauveTexte
Creates and fills a text file with the content of a text control or text variable (string variable, edit control in a window, Static control in a report, ...). If the file already exists, it is deleted then re-created.
Remark: The strings containing binary "0" ("\0") are supported.
<Result> = fSaveText(<Name and path of the text file> , <Content>)
- True if the operation was successful,
- False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Name and path of the text file>: Character string
Name and full (or relative) path of text file to create. A UNC path can be used.
This parameter can be in Ansi or Unicode format.
<Content>: Character string
String containing the content of the file.
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).
: 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.
fSaveText is equivalent to the following code:
// Opens the file in read-only
f is int = fOpen("C:\MyFile.txt", foCreate)
// Writes into the file
FileContent is string = "example of text"
// Closes the file
This page is also available for…