Saltar para o conteúdo principal
Versão: 20 R5 BETA

Document Class

Descrição

.creationDate

História
ReleaseMudanças
17 R5Adicionado

.creationDate : Date

Descrição

The .creationDate property returns the creation date of the file.

This property is read-only.

.creationTime

História
ReleaseMudanças
17 R5Adicionado

.creationTime : Time

Descrição

The .creationTime property returns the creation time of the file (expressed as a number of seconds beginning at 00:00).

This property is read-only.

.exists

História
ReleaseMudanças
17 R5Adicionado

.exists : Boolean

Descrição

The .exists property returns true if the file exists on disk, and false otherwise.

This property is read-only.

.extension

História
ReleaseMudanças
17 R5Adicionado

.extension : Text

Descrição

The .extension property returns the extension of the file name (if any). Uma extensão sempre começa com ".". Uma extensão sempre começa com "." A propriedade devolve uma string vazia se o nome do arquivo não tiver extensão.

This property is read-only.

.fullName

História
ReleaseMudanças
17 R5Adicionado

.fullName : Text

Descrição

The .fullName property returns the full name of the file, including its extension (if any).

This property is read-only.

.hidden

História
ReleaseMudanças
17 R5Adicionado

.hidden : Boolean

Descrição

The .hidden property returns true if the file is set as "hidden" at the system level, and false otherwise.

This property is read/write.

.isAlias

História
ReleaseMudanças
17 R5Adicionado

.isAlias : Boolean

Descrição

The .isAlias property returns true if the file is an alias, a shortcut, or a symbolic link, and false otherwise.

This property is read-only.

.isFile

História
ReleaseMudanças
17 R5Adicionado

.isFile : Boolean

Descrição

The .isFile property returns always true for a file.

This property is read-only.

.isFolder

História
ReleaseMudanças
17 R5Adicionado

.isFolder : Boolean

Descrição

The .isFolder property returns always false for a file.

This property is read-only.

.isWritable

História
ReleaseMudanças
17 R5Adicionado

.isWritable : Boolean

Descrição

The .isWritable property returns true if the file exists on disk and is writable.

The property checks the ability of the 4D application to write on the disk (access rights), it does not solely rely on the writable attribute of the file.

This property is read-only.

Exemplo

 $myFile:=File("C:\\Documents\\Archives\\ReadMe.txt";fk platform path)
If($myFile.isWritable)
$myNewFile:=$myFile.setText("Added text")
End if

.modificationDate

História
ReleaseMudanças
17 R5Adicionado

.modificationDate : Date

Descrição

The .modificationDate property returns the date of the file's last modification.

This property is read-only.

.modificationTime

História
ReleaseMudanças
17 R5Adicionado

.modificationTime : Time

Descrição

The .modificationTime property returns the time of the file's last modification (expressed as a number of seconds beginning at 00:00).

This property is read-only.

.name

História
ReleaseMudanças
17 R5Adicionado

.name : Text

Descrição

The .name property returns the name of the file without extension (if any).

This property is read-only.

.original

História
ReleaseMudanças
17 R5Adicionado

.original : 4D.File
.original : 4D.Folder

Descrição

The .original property returns the target element for an alias, a shortcut, or a symbolic link file. O elemento alvo pode ser:

  • um objeto File
  • um objeto folder

Para arquivos não-alias, a propriedade retorna o mesmo objeto de arquivo que o arquivo.

This property is read-only.

.parent

História
ReleaseMudanças
17 R5Adicionado

.parent : 4D.Folder

Descrição

The .parent property returns the parent folder object of the file. .

This property is read-only.

.path

História
ReleaseMudanças
17 R5Adicionado

.path : Text

Descrição

The .path property returns the POSIX path of the file. .

This property is read-only.

.platformPath

História
ReleaseMudanças
17 R5Adicionado

.platformPath : Text

Descrição

The .platformPath property returns the path of the file expressed with the current platform syntax.

This property is read-only.

.size

História
ReleaseMudanças
17 R5Adicionado

.size : Real

Descrição

The .size property returns the size of the file expressed in bytes. Se o arquivo não existir em disco, o tamanho é 0.

This property is read-only.

.copyTo()

História
ReleaseMudanças
17 R5Adicionado

.copyTo( destinationFolder : 4D.Folder { ; newName : Text } { ; overwrite : Integer } ) : 4D.File

ParâmetroTipoDescrição
destinationFolder4D. Folder->Pasta de destino
newNameText->Nome para a copia
overwriteInteger->fk overwrite to replace existing elements
Resultados4D. File<-Arquivo copiado

Descrição

The .copyTo() function copies the File object into the specified destinationFolder .

The destinationFolder must exist on disk, otherwise an error is generated.

Como padrão, o arquivo é copiado com o nome do arquivo original. If you want to rename the copy, pass the new name in the newName parameter. O novo nome deve cumprir com as regras de nomenclatura (por exemplo, não deve conter caracteres como ":", "/", etc.), do contrário se devolve um erro.

If a file with the same name already exists in the destinationFolder, by default 4D generates an error. You can pass the fk overwrite constant in the overwrite parameter to ignore and overwrite the existing file

ParâmetrosValorComentário
fk overwrite4Sobrescrever os elementos existentes, se houver

Valor retornado

The copied File object.

Exemplo

You want to copy a picture file from the user's document folder to the application folder:

var $source; $copy : Object
$source:=Folder(fk documents folder).file("Pictures/photo.png")
$copy:=$source.copyTo(Folder("/PACKAGE");fk overwrite)

.getContent()

História
ReleaseMudanças
19 R2Returns 4D. Blob
17 R5Adicionado

.getContent( ) : 4D.Blob

ParâmetroTipoDescrição
Resultados4D. Blob<-Conteúdo do arquivo

Descrição

The .getContent() function returns a 4D.Blob object containing the entire content of a file. For information on BLOBs, please refer to the BLOB section.

Valor retornado

A 4D.Blob object.

Exemplo

To save a document's contents in a BLOB field:

 var $vPath : Text
$vPath:=Select document(""; "*"; "Select a document";0)
If(OK=1) //Se tiver sido escolhido um documento
[aTable]aBlobField:=File($vPath;fk platform path).getContent()
End if

.getIcon()

História
ReleaseMudanças
17 R5Adicionado

.getIcon( { size : Integer } ) : Picture

ParâmetroTipoDescrição
sizeInteger->Longitude de lado da imagem devolvida (píxeles)
ResultadosImagem<-Ícone

Descrição

The .getIcon() function returns the icon of the file.

The optional size parameter specifies the dimensions in pixels of the returned icon. Este valor representa em realidade a longitude do lado do quadrado que contém o icone. Icones são geralmente definidos como 32x32 píxels ('icones grandes') ou 16x16 ('icones pequenos'). Se passar 0 ou omitir este parâmetro, se devolve a versão 'icone grande'

Se o arquivo não existir no disco, um ícone em branco padrão será retornado.

Valor retornado

File icon picture.

.getText()

História
ReleaseMudanças
17 R5Adicionado

.getText( { charSetName : Text { ; breakMode : Integer } } ) : Text
.getText( { charSetNum : Integer { ; breakMode : Integer } } ) : Text

ParâmetroTipoDescrição
charSetNameText->Nome do conjunto de caracteres
charSetNumInteger->Número de conjuntos de caracteres
breakModeInteger->Modo de processamento para quebras de linha
ResultadosText<-Texto do documento

Descrição

The .getText() function returns the contents of the file as text .

Opcionalmente, você pode designar o conjunto de caracteres a ser usado na leitura do conteúdo. Você pode passar também:

  • in charSetName, a string containing the standard set name (for example "ISO-8859-1" or "UTF-8"),
  • or in charSetNum, the MIBEnum ID (number) of the standard set name.

For the list of character sets supported by 4D, refer to the description of the CONVERT FROM TEXT command.

If the document contains a Byte Order Mark (BOM), 4D uses the character set that it has set instead of the one specified in charSetName or charSetNum (this parameter is then ignored). If the document does not contain a BOM and if charSetName or charSetNum is omitted, by default 4D uses the "UTF-8" character set.

In breakMode, you can pass a number indicating the processing to apply to end-of-line characters in the document. As seguintes constantes do tema "Documentos do Sistema" estão disponíveis:

ParâmetrosValorComentário
Document unchanged0Não processado
Document with native format1(Padrão) As quebras de linha são convertidas para o formato nativo do sistema operacional: CR (retorno de carro) sob OS X, CRLF (retorno do carro + salto de linha) em Windows
Documento com CRLF2Quebras de linha são convertidas em formato Windows: CRLF (retorno de carro + quebra de linha)
Documento com CR3Quebras de linha são convertidas para o formato OS X: CR (retorno de carro)
Documento com LF4Quebras de linha são convertidas em formato Unix: LF (feed de linha)

By default, when you omit the breakMode parameter, line breaks are processed in native mode (1).

Valor retornado

Texto do arquivo.

Exemplo

Dado o seguinte documento de texto (os campos são separados por tabulações):

id name price vat
3 thé 1.06€ 19.6
2 café 1.05€ 19.6

Quando você executar este código:

 $myFile:=Folder(fk documents folder).file("Billing.txt") //UTF-8 por padrão
$txt:=$myFile.getText()

... you get the following for $txt:

"id\tname\tprice\tvat\r\n3\tthé\t1.06€\t19.6\r\n2\tcafé\t1.05€\t19.6"

with \t (tab) as separator and \r\n (CRLF) as line delimiter.

Aqui está outro exemplo com o mesmo arquivo, mas um delimitador de linha diferente:

 $txt:=$myFile.getText("UTF-8"; Document with LF)

In this case, the contents of $txt are as follows:

"id\tname\tprice\tvat\n3\tthé\t1.06€\t19.6\n2\tcafé\t1.05€\t19.6"

This time \n (LF) is used as line delimiter.