AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de archivos externos
  • Handling errors
  • Operating mode in Windows Vista (and later)
  • Carriage Return at the end of line
  • Position in the file
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Writes a block of bytes to an external file.
Please note Added elements are not inserted into the external file, but overwrite existing elements.
Ejemplo
WINDEVWEBDEV - Código ServidorReportes y ConsultasJavaCódigo de Usuario (UMC)Ajax
// Ouverture d'un fichier externe 
MonFichierTxt is DiskFile
ResEcriture is int
IF MonFichierTxt.Ouvre("C:\MesRépertoires\Fichier.txt", foReadWrite) = True THEN
	// Écriture dans ce fichier
	ResEcriture = MonFichierTxt.Ecrit("Compte-rendu de la réunion")
	IF ResEcriture <> -1 THEN
		// ...
	END
END
Sintaxis

Escritura de un bloque de bytes en un archivo externo Ocultar los detalles

<Result> = <File used>.Write(<Block to write> [, <Size to write>])
<Result>: Integro
  • Number of bytes written to the file.
  • -1 if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
<File used>: Variable de tipo DiskFile
Name of the DiskFile variable initialized with <DiskFile variable>Abrir or <DiskFile variable>.Create.
<Block to write>: Cadena de caracteres
Block of bytes to must be written to the file (up to 2 GB).
The format of the block of bytes is respected. No conversion is performed.
<Size to write>: Entero opcional
Size of the string to write (in bytes).
WINDEVWEBDEV - Código ServidorReportes y ConsultasCódigo de Usuario (UMC)Ajax

Escritura de una sección de memoria en un archivo externo (velocidad rápida) Ocultar los detalles

<Result> = <File used>.Write(<Address of memory section> , <Size to write>)
<Result>: Integro
  • Number of bytes (characters) written to the file,
  • -1 if an error occurred. To get more details on the error, use ErrorInfo with the errMessage constant.
<File used>: Variable de tipo DiskFile
Name of the DiskFile variable initialized with <DiskFile variable>Abrir or <DiskFile variable>.Create.
<Address of memory section>: Dirección
Address of the memory section to be written to the file.
<Size to write>: Integro
Size (in bytes) to be written to the external file (up to 2 Go).
This parameter must be less than or equal to the real size of the element written to the external file. For example, if the size of the element to write is equal to 100 bytes, <Size to write> must be less than or equal to 100 bytes.
If this parameter is less than the real size of the written element, only the specified number of bytes will be written to the external file.
Observaciones

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.
WINDEVWEBDEV - Código ServidorReportes y ConsultasCódigo de Usuario (UMC)

Operating mode in Windows Vista (and later)

If this function does not work 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: If you need to manipulate / modify files or directories, without needing administrator privileges, it is advisable:
  • 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: Under Windows Vista (and higher), the virtualization mechanism makes applications Vista-compatible.. 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.

Carriage Return at the end of line

<DiskFile variable>WriteLine 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:
MonFichier is DiskFile
...
ResEcriture = MyFile.Ecrit("Compte-rendu" + CR + "Ventes de mars 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).
This position can be modified by <DiskFile variable>.Seek.
<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.
Note: To always read the beginning of the zone, use the <DiskFile variable>.Seek function and then the <DiskFile variable>.leer function..
Clasificación Lógica de negocio / UI: Lógica de negocio
Componente: wd300std.dll
Versión mínima requerida
  • Versión 28
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 30/09/2024

Señalar un error o enviar una sugerencia | Ayuda local