|
|
|
|
|
- Handling errors
- Operating mode in Windows Vista (and later)
- File opening mode
- Multiple openings of the same file
- Position in the file
- Concatenating several external files
- Compatibility between different versions of WINDEV/WEBDEV
- Locking and unlocking
- Managing UNICODE text files
<DiskFile variable>.Open (Function) In french: <Variable FichierDisque>.Ouvre Open an external file (ANSI or UNICODE) to manipulate it programmatically. Remarks:
MonFichierExterne is DiskFile
ResOuverture is boolean
ResOuverture = MonFichierExterne.Open("C:\MesRépertoires\Fichier.txt", foReadWrite)
IF ResOuverture THEN
...
END
Syntax
Opening an external file and initializing a DiskFile variable Hide the details
<Result> = <DiskFile>.fOpen(<File to manipulate> [, <Opening mode>])
<Result>: Boolean - True if the file was opened and associated with variable of type DiskFile,
- False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<DiskFile>: DiskFile variable Name of the DiskFile variable to be associated with the manipulated text file. <File to manipulate>: Character string Name and full or relative path of the file (up to 260 characters). A UNC path can be used.
<Opening mode>: Optional constant (or combination of constants) Constants used to define the opening mode of the file, the access mode to the file and the lock mode of the file. Remarks Handling errors <DiskFile variable>.Open throws an error in the following cases: - the file does not exist,
- the file is locked by another computer or by another application,
- the user has no read or write rights on the file to open.
File opening mode By default, if the access mode to the file is not specified, the file is opened according to the file attribute (defined in Windows). An error occurs if the specified access mode does not correspond to the file attribute. A file in "read/write" mode can be opened in all the access modes supported by <DiskFile variable>.Open (foWrite, foRead and foReadWrite constants). A file in "read-only" mode can only be opened in "read-only" mode (foRead constant). Multiple openings of the same file The same file can be opened several times simultaneously. Each opening is associated with a different file identifier. Each version of the file must be handled individually via its own identifier. Position in the file When opening a file, the current position corresponds to: - the first file byte,
- the last byte of the file is the file is opened in "addition" mode (foAdd constant).
Concatenating several external files To concatenate several external files, you must: - open the destination file in "addition" mode (foAdd constant),
- open the source file in "read-only" mode (foRead or foReadWrite constant),
- read the source file line by line with <DiskFile variable>.ReadLine,
- write into the destination file line by line with <DiskFile variable>.WriteLine.
Compatibility between different versions of WINDEV/WEBDEV The foText constant (opening in text mode) and the foBinary constant (opening in binary mode) are not required anymore. They are replaced with the value 0. In this case, <DiskFile variable>.Open tries to open the file in read/write mode. Business / UI classification: Business Logic
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|