| CloseFile |
closes the opened file, automatically called when the class terminates |
| Eof |
returns true if the file pointer is at the End Of File |
| Flush |
flushes operation |
| GetFilePos |
returns the position of the file pointer |
| IsFileOpen |
checks if the class is managing a file |
| Lof |
gets the size of the opened file |
| OpenFileAppend |
uses OpenFileGeneric for opening a file for appending |
| OpenFileGeneric |
opens a file, you can use any combination of enum values for input parameters |
| OpenFileRead |
uses OpenFileGeneric for opening a file for reading |
| OpenFileWrite |
uses OpenFileGeneric for opening a file for writing |
| OpenedFileHandle |
returns the handle of the opened file managed by the class |
| OpenedFileName |
returns the name of the opened file managed by the class |
| ReadAnsiLine |
reads an Ansi line from file (stops when find a LF char). See the ReadBOM function. |
| ReadAny |
reads n bytes from file and fill a certain variable |
| ReadBOM |
reads the file encoding identifier contained at the top of the file and returns the file encoding used.
This function must be used every time you want to read a text file using the ReadAnsiLine and ReadUnicodeLine functions.
Sample:
'Read each line in file If CFile.OpenFileRead(fileName) Then fEncoding = CFile.ReadBOM()
While Not CFile.EOF() 'Read line from file If (fEncoding = fe_ANSI) Then rc = CFile.ReadAnsiLine(inStrg) Else rc = CFile.ReadUnicodeLine(inStrg) End If If (rc = False) Then GoTo FILE_ERR Wend CFile.CloseFile End If
...OR...
'Read each line in file If CFile.OpenFileRead(fileName) Then fEncoding = CFile.ReadBOM()
While Not CFile.EOF() 'Read line from file rc = CFile.ReadLine(inStrg,fEncoding) If (rc = False) Then GoTo FILE_ERR Wend CFile.CloseFile End If
|
| ReadByte |
reads a byte from file and return true if the operation finished correctly |
| ReadBytes |
reads n byte from file and return true if the operation finished correctly |
| ReadInt |
reads an integer from file (2 bytes) |
| ReadLine |
reads a line with the given file encoding (ansi, unicode, utf8). |
| ReadLong |
reads a long from file (4 bytes) |
| ReadUTF8Line |
reads an UTF8 line from file (stops when find a LF char). See the ReadBOM function. (Same as ReadAnsiLine + UTF8ToStr). |
| ReadUnicodeLine |
reads an Unicode line from file (stops when find a 00 - LF wchar). See the ReadBOM function. |
| SetEndOfFileHere |
sets the EOF at the current file position |
| SetFilePos |
moves the file pointer |
| WriteAnsiLine |
writes an Ansi line to file and append a CrLf char. See the WriteBOM function. |
| WriteAny |
writes n bytes to file reading from a certain variable |
| WriteBOM |
writes the file encoding identifier in the file; - for ANSI it is not used, the function returns ok - for UTF8 it writes 3 bytes - for UTF16 it writes 2 bytes.
If you want to make a standard Unicode UTF8/UTF16 file you have to write the BOM at the top of the file.
The function "st_GetFileEncoding" detects the encoding using the BOM.
Sample:
'Write lines into file If CFile.OpenFileWrite(fileName) Then If (bWriteAnsi) Then
CFile.WriteBOM fe_ANSI CFile.WriteAnsiLine "Test Line 1" CFile.WriteAnsiLine "Test Line 2" CFile.WriteAnsiLine "Test Line 3" CFile.WriteAnsiLine "Test Line 4"
Else
CFile.WriteBOM fe_UTF16LE CFile.WriteUnicodeLine "Test Line 1" CFile.WriteUnicodeLine "Test Line 2" CFile.WriteUnicodeLine "Test Line 3" CFile.WriteUnicodeLine "Test Line 4"
End If CFile.CloseFile End If |
| WriteByte |
writes a byte to file and return true if the operation finished correctly |
| WriteBytes |
writes n bytes to file and return true if the operation finished correctly |
| WriteInt |
writes an integer to file (2 bytes) |
| WriteLine |
writes a line with the given encoding (ansi, unicode, utf8). |
| WriteLong |
writes a long to file (4 bytes) |
| WriteNumCharsAndString / ReadNumCharsAndString |
writes/reads a binary string to file |
| WriteUTF8Line |
writes a UTF8 line to file and append a CrLf char. See the WriteBOM function. (Same as StrToUTF8 + WriteAnsiLine). |
| WriteUnicodeLine |
writes an Unicode line to file and append a CrLf wchar. See the WriteBOM function. |