Method: GetCharacters for File
- Updated2024-09-12
- 1 minute(s) read
DataPlugin > Methods > Method: GetCharacters for File
Method: GetCharacters for File
Reads a specific number of characters from the file. The method returns all characters, including delimiters and end of line characters.
sGetCharacters = Object.GetCharacters(Number)
Object | File Object with this method |
Number | LongInteger Specifies the number of characters to read. |
sGetCharacters | String Receives the characters that have been read out. |
![]() | Note If GetCharacters finds the character "\0" before it has read the specified number of characters, GetCharacters returns only the characters it has read up to that point. |
The following example reads up to 1000 characters from a file and determines the end of line character for the file.
Dim BytesToRead, ByteStream, i BytesToRead = 1000 If (BytesToRead > File.Size) Then BytesToRead = File.Size ByteStream = File.GetCharacters(BytesToRead)) If (0 < Instr(ByteStream,vbNewLine)) Then File.Formatter.LineFeeds = vbNewLine ElseIf (0 < Instr(ByteStream,vbCR)) Then File.Formatter.LineFeeds = vbCR ElseIf (0 < Instr(ByteStream,vbLF)) Then File.Formatter.LineFeeds = vbLF End If