- Handling errors
- Operating mode in Windows Vista (and later)
- Carriage Return at the end of line
- Position in the file
<DiskFile variable>.Write (Function) In french: <Variable FichierDisque>.Ecrit Writes a block of bytes into an external file. Caution: The added elements are not inserted into the external file but they overwrite the existing elements.
Syntax
Writing a block of bytes into an external file Hide the details
<Result> = <File used>.Write(<Block to write> [, <Size to write>])
<Result>: Integer - Number of bytes written into the file.
- -1 if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
<File used>: DiskFile variable Name of the DiskFile variable initialized with fOpen or fCreate. <Block to write>: Character string Block of bytes that must be written into the file (up to 2 GB).The format of the block of bytes is respected. No conversion is performed. <Size to write>: Optional integer Size of the string to write (in bytes). Remarks Handling errors <DiskFile variable>.Write throws an error in the following cases: - the file is not opened,
- the file is not accessible in write mode,
- the file is locked by another computer or by another application,
- no disk space is available.
Carriage Return at the end of line <Variable FichierDisque>.EcritLigne is used to automatically insert a carriage return (CR) at the end of the added line. To insert a Carriage Return (CR) with <DiskFile variable>.Write, simply use the CR constant. For example:
MyFile is DiskFile ... ResWrite = MyFile.Write("Report" + CR + "Sales - March 2021")
Position in the file When opening a file, the current position corresponds to: - the first file byte (by default),
- the last byte of the file is the file is opened in "addition" mode (foAdd constant).
<DiskFile variable>.Write writes the specified elements from the current position. Once <DiskFile variable>.Write has been executed, the current position is set to the last byte written. Business / UI classification: Business Logic
This page is also available for…
|
|
|
|